方法1
- 下载二进制包 然后解压
tar xzvf docker-19.03.5.tgz
- 将解压出来的 docker 文件所有内容移动到 /usr/bin/ 目录下
cp docker/* /usr/bin/
- 开启 docker 守护进程
sudo /usr/bin/dockerd &
- 测试是否安装成功
docker --version
docker ps -a
- 注册系统服务
vim /usr/lib/systemd/system/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
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
- 重载服务与开机自启
# 重载服务
systemctl daemon-reload
# 开机自启动
systemctl enable docker.service
方法二(更简单)
-
下载rpm安装文件
-
安装
sudo yum install /path/to/package.rpm
- 启动docker
sudo systemctl start docker
- 验证安装是否成功
docker --version
docker ps -a
网友评论