一、下载安装包,选择适合版本,本次安装选择20.10.7
Index of linux/static/stable/x86_64/
二、安装
1、将下载的安装文件进行解压,命令如下
tar -xzf docker-20.10.7.tar
2、将上述解压后文件(docker文件夹)全部移动至/usr/bin目录下(必须),命令如下
mv docker/* /usr/bin/
3、注册docker.service服务
vi /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
4、添加可执行权限:
chmod +x /usr/lib/systemd/system/docker.service
systemctl daemon-reload
5、编辑daemon.json
vi /etc/docker/daemon.json
#找一个阿里云的私库
{
"registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]
}
systemctl daemon-reload
6、将中标麒麟虚拟机改为桥接模式(不是虚拟机不需要)
7、关闭防火墙(非常重要,不然无法启动)
systemctl disable firewalld
chkconfig iptables off
8、启动docker
systemctl start docker.service
9、查看docker状态
三、运行第一个实例 helloworld
1、从仓库拉取 helloworld
2、运行