各操作系统版本下载地址
mac 版:https://download.docker.com/mac
linux版:https://download.docker.com/linux
win版:https://download.docker.com/win
dmg方式:官网下载安装包.dmg 直接安装即可。(安装步骤略)
也可以使用tgz方式,手动安装,安装教程同下,只不过使用的包是mac版。
mac版tgz包下载:https://download.docker.com/mac/static/stable/x86_64/ tgz的安装步骤,参看下文。
yum方式安装:yum install -y docker-ce
shell在线安装:curl -sSL https://get.docker.com | sh
以上两种方式,均需要服务器能连接外网,且安装简单快捷。
当服务器无法连接外网时,推荐使用tgz包方式手动安装,这也是本文接下来重点描述的安装步骤。
进入官网下载目录:https://download.docker.com/linux/static/stable/x86_64/
选择合适的版本进行下载,这里我选择的20.10.9版本。下载到的安装包是:docker-20.10.9.tgz
其他芯片架构-操作系统:https://download.docker.com/linux/static/stable/
Index of linux/static/stable/
../
aarch64/
armel/
armhf/
ppc64le/
s390x/
x86_64/
scp Downloads/docker-20.10.9.tgz admin@20.110.10.39:/data01/soft/
登录服务器,解压安装包
[admin@kratos-preserver-d-010039 soft]$ cd /data01/soft
[admin@kratos-preserver-d-010039 soft]$ tar -xvf docker-20.10.9.tgz
docker/
docker/containerd-shim-runc-v2
docker/dockerd
docker/docker-proxy
docker/ctr
docker/docker
docker/runc
docker/containerd-shim
docker/docker-init
docker/containerd
[admin@kratos-preserver-d-010039 soft]$ cd docker
[admin@kratos-preserver-d-010039 docker]$ ls -la
total 200844
drwxr-xr-x 2 admin admin 169 Oct 5 2021 .
drwxrwxrwx. 11 admin admin 4096 Mar 20 16:17 ..
-rwxr-xr-x 1 admin admin 33908392 Oct 5 2021 containerd
-rwxr-xr-x 1 admin admin 6508544 Oct 5 2021 containerd-shim
-rwxr-xr-x 1 admin admin 8609792 Oct 5 2021 containerd-shim-runc-v2
-rwxr-xr-x 1 admin admin 21131264 Oct 5 2021 ctr
-rwxr-xr-x 1 admin admin 52883616 Oct 5 2021 docker
-rwxr-xr-x 1 admin admin 64758736 Oct 5 2021 dockerd
-rwxr-xr-x 1 admin admin 708616 Oct 5 2021 docker-init
-rwxr-xr-x 1 admin admin 2784145 Oct 5 2021 docker-proxy
-rwxr-xr-x 1 admin admin 14352296 Oct 5 2021 runc
[admin@kratos-preserver-d-010039 soft]$sudo cp docker/* /usr/bin/
[admin@kratos-preserver-d-010039 soft]$ cd /etc/systemd/system/
[admin@kratos-preserver-d-010039 system]$ sudo vim docker.service
填写内容
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target[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 tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
# 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
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# 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
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s[Install]
WantedBy=multi-user.target
[admin@kratos-preserver-d-010039 system]$ sudo chmod +x /etc/systemd/system/docker.service
[admin@kratos-preserver-d-010039 system]$ sudo systemctl daemon-reload
[admin@kratos-preserver-d-010039 system]$ sudo systemctl start docker
[admin@kratos-preserver-d-010039 system]$ sudo systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.
[admin@kratos-preserver-d-010039 system]$ systemctl status docker
● docker.service - Docker Application Container EngineLoaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)Active: active (running) since Mon 2023-03-20 16:20:47 CST; 24s agoDocs: https://docs.docker.comMain PID: 2766 (dockerd)CGroup: /system.slice/docker.service├─2766 /usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock└─2809 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
[admin@kratos-preserver-d-010039 system]$ docker -v
Docker version 20.10.9, build c2ea9bc