一、官网下载离线包


https://download.docker.com/linux/static/stable/


选择自己需要的版本

二、上传至虚拟机,解压安装包

1.将二进制文件移动到可执行路径上的目录

cp docker/* /usr/bin/

2.准备docker.service 系统配置文件

vim /etc/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

3.查看有无并添加执行权限

chmod +x docker.service

4.重启服务读取配置文件

systemctl daemon-reload

5.启动docker

systemctl start docker

查看状态

systemctl status docker

 6.docker-v

docker images命令来查看docker中的镜像。

7.配置镜像加速器

vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

重载配置

systemctl daemon-reload

重启docker

systemctl restart docker

是否生效

docker info | grep "Registry Mirrors" -A 1

更多推荐