• 基于Ubuntu20.04.01

1.下载docker的安装文件
https://download.docker.com/linux/static/stable/x86_64/

2.把安装文件上传至/tmp

3.解压

1
tar -zxvf docker-20.10.1.tgz

4.将解压出来的docker文件复制到 /usr/bin/ 目录下

1
cp docker/* /usr/bin/

5.进入/etc/systemd/system/目录,并创建docker.service文件

1
2
cd /etc/systemd/system/
touch docker.service

6.修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
vi docker.service	#修改IP为本机服务器IP

[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 --selinux-enabled=false --insecure-registry=192.168.200.128
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

7.给docker.service文件添加执行权限

1
chmod 777 /etc/systemd/system/docker.service

8.加载配置文件

1
systemctl daemon-reload

9.启动&设置开机启动

1
2
systemctl start docker
systemctl enable docker.service

10.查看docker状态&配置镜像加速器

1
2
3
4
5
6
systemctl status docker
vi /etc/docker/daemon.json

{
"registry-mirrors": ["https://cliyj1oa.mirror.aliyuncs.com"]
}