1.2.2.3 Linux 二进制安装
本方法适用于无法上网或无法通过包安装方式安装的主机上安装docker
安装文档:https://docs.docker.com/engine/install/binaries/
二进制安装下载路径
https://download.docker.com/linux/
https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/
在Centos 8上实现二进制安装docker
[root@centos8 ~]# wget https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-19.03.15.tgz
--2021-07-07 10:32:29-- https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-19.03.15.tgz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 27.221.120.241, 27.221.120.240, 27.221.120.238, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|27.221.120.241|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 62436240 (60M) [application/octet-stream]
Saving to: ‘docker-19.03.15.tgz’
docker-19.03.15.tgz 100%[=========================>] 59.54M 540KB/s in 1m 58s
2021-07-07 10:34:28 (515 KB/s) - ‘docker-19.03.15.tgz’ saved [62436240/62436240]
[root@centos8 ~]# tar xvf docker-19.03.15.tgz
docker/
docker/dockerd
docker/docker-proxy
docker/containerd-shim
docker/docker-init
docker/docker
docker/runc
docker/ctr
docker/containerd
[root@centos8 ~]# cp docker/* /usr/bin/
# 启动docker服务
[root@centos8 ~]# dockerd &>/dev/null &
[1] 1445
[root@centos8 ~]# docker version
Client: Docker Engine - Community
Version: 19.03.15
API version: 1.40
Go version: go1.13.15
Git commit: 99e3ed8
Built: Sat Jan 30 03:11:43 2021
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.15
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 99e3ed8
Built: Sat Jan 30 03:18:13 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.9
GitCommit: ea765aba0d05254012b0b9e595e995c09186427f
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
[root@centos8 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:9f6ad537c5132bcce57f7a0a20e317228d382c3cd61edae14650eec68b2b345c
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
[root@centos8 ~]# pstree -p
systemd(1)─┬─NetworkManager(835)─┬─{NetworkManager}(850)
│ └─{NetworkManager}(852)
├─VGAuthService(822)
├─agetty(895)
├─auditd(794)───{auditd}(795)
├─crond(882)
├─dbus-daemon(832)
├─irqbalance(836)───{irqbalance}(844)
├─polkitd(825)─┬─{polkitd}(849)
│ ├─{polkitd}(851)
│ ├─{polkitd}(854)
│ ├─{polkitd}(856)
│ ├─{polkitd}(857)
│ ├─{polkitd}(858)
│ ├─{polkitd}(859)
│ ├─{polkitd}(860)
│ ├─{polkitd}(861)
│ ├─{polkitd}(862)
│ └─{polkitd}(872)
├─rngd(839)───{rngd}(848)
├─rsyslogd(1121)─┬─{rsyslogd}(1132)
│ └─{rsyslogd}(1134)
├─sshd(863)───sshd(1390)───sshd(1402)───bash(1403)─┬─dockerd(1445)─┬─containe+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ ├─{dockerd+
│ │ └─{dockerd+
│ └─pstree(1770)
├─sssd(829)─┬─sssd_be(868)
│ └─sssd_nss(871)
├─systemd(1393)───(sd-pam)(1395)
├─systemd-journal(714)
├─systemd-logind(877)
├─systemd-udevd(750)
├─tuned(855)─┬─{tuned}(1087)
│ ├─{tuned}(1093)
│ └─{tuned}(1096)
└─vmtoolsd(823)─┬─{vmtoolsd}(874)
└─{vmtoolsd}(881)
创建相关的service文件,此方式新版本有问题
# 创建相关的service文件,此方式新版有问题
[root@centos8 ~]# groupadd -r docker
# 将ubuntu1804或centos7基于包方式安装的相关文件复制到相应目录下
[root@ubuntu1804 ~]# ll /lib/systemd/system/docker.*
-rw-r--r-- 1 root root 1683 Jan 30 11:15 /lib/systemd/system/docker.service
-rw-r--r-- 1 root root 197 Jan 30 11:15 /lib/systemd/system/docker.socket
[root@ubuntu1804 ~]# scp /lib/systemd/system/docker.* 10.0.0.8:/usr/lib/systemd/system/
root@10.0.0.8's password:
docker.service 100% 1683 2.3MB/s 00:00
docker.socket 100% 197 213.7KB/s 00:00
[root@ubuntu1804 ~]# ll /lib/systemd/system/containerd.service
-rw-r--r-- 1 root root 1263 May 21 15:30 /lib/systemd/system/containerd.service
[root@ubuntu1804 ~]# scp /lib/systemd/system/containerd.service 10.0.0.8:/usr/lib/systemd/system/
root@10.0.0.8's password:
containerd.service 100% 1263 1.9MB/s 00:00
[root@centos8 ~]# ll /usr/lib/systemd/system/docker.*
-rw-r--r-- 1 root root 1683 Jul 7 10:40 /usr/lib/systemd/system/docker.service
-rw-r--r-- 1 root root 197 Jul 7 10:40 /usr/lib/systemd/system/docker.socket
[root@centos8 ~]# cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
[Install]
WantedBy=multi-user.target
[root@centos8 ~]# cat /usr/lib/systemd/system/docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
[root@centos8 ~]# ll /usr/lib/systemd/system/containerd.service
-rw-r--r-- 1 root root 1263 Jul 7 10:43 /usr/lib/systemd/system/containerd.service
[root@centos8 ~]# cat /usr/lib/systemd/system/containerd.service
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=1048576
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
[root@centos8 ~]# systemctl daemon-reload
[root@centos8 ~]# killall dockerd
[root@centos8 ~]# systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@centos8 ~]# docker version
Client: Docker Engine - Community
Version: 19.03.15
API version: 1.40
Go version: go1.13.15
Git commit: 99e3ed8
Built: Sat Jan 30 03:11:43 2021
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.15
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 99e3ed8
Built: Sat Jan 30 03:18:13 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.9
GitCommit: ea765aba0d05254012b0b9e595e995c09186427f
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683







Comments | NOTHING