docker离线安装+升级
# docker 离线安装
# docker 离线安装
# 1. 下载安装包
选择对应版本下载
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.17.tgz
1
# 2. 解压
tar -zxvf docker-20.10.17.tgz
1
# 3. 将解压出来的docker文件复制到 /usr/bin/ 目录下
cp docker/* /usr/bin/
1
如果提示 cp:是否覆盖'/usr/bin/runc'?
选择否,否则docker无法正常运行!!!
如果提示 cp:是否覆盖'/usr/bin/runc'?
选择否,否则docker无法正常运行!!!
如果提示 cp:是否覆盖'/usr/bin/runc'?
选择否,否则docker无法正常运行!!!
# 4. 在/etc/systemd/system/目录下新增docker.service文件,内容如下,这样可以将docker注册为service服务
cat >/etc/systemd/system/docker.service<<EOF
[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
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
EOF
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
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
给docker.service文件添加执行权限
chmod +x /etc/systemd/system/docker.service
1
重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
systemctl daemon-reload
1
# 5. 启动 docker
#启动
systemctl start docker
#设置开机启动
systemctl enable docker.service
#查看docker服务状态
systemctl status docker
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
上面显示 Active: active (running)
表示 docker 已安装成功
# 6. 配置 docker 国内镜像地址
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
systemctl restart docker
1
2
3
4
5
2
3
4
5
首页点击 创建我的容器镜像 得到一个专属的镜像加速地址,类似于 https://1234abcd.mirror.aliyuncs.com
# docker 离线升级
# 1. 下载安装包
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.17.tgz
1
# 2. 解压并停止 docker
#解压
tar -zxvf docker-20.10.17.tgz
#停止docker
sudo systemctl stop docker
1
2
3
4
2
3
4
# 3. 将解压出来的 docker 文件复制到 /usr/bin/ 目录下
sudo cp docker/* /usr/bin/
1
如果提示 cp:是否覆盖'/usr/bin/runc'?
选择否,否则docker无法正常运行!!!
如果提示 cp:是否覆盖'/usr/bin/runc'?
选择否,否则docker无法正常运行!!!
如果提示 cp:是否覆盖'/usr/bin/runc'?
选择否,否则docker无法正常运行!!!
# 4. 重新启动 docker
#启动
sudo systemctl start docker
#查看docker服务状态
sudo systemctl status docker
1
2
3
4
5
2
3
4
5
上面显示 Active: active (running)
表示 docker 已升级成功
上次更新: 2024/05/11, 03:55:33