docker离线包安装和卸载

发布时间 2023-07-11 15:47:59作者: 悲伤往事

离线包安装docker

1.配置基础环境
操作系统:CentOS 7.8
Docker版本:19.03.5
包下载地址:

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

2.本地安装Docker
2.1本地进行解压

tar -xvf docker-19.03.5.tgz

2.2将解压出来的docker目录下的所有文件内容移动到/usr/bin/目录下面

mv docker/* /usr/bin/

2.3将Docker注册为service

vi /etc/systemd/system/docker.service

将下面的配置加入到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

2.4启动Docker服务
添加文件的执行权限并启动Docker服务

chmod +x /etc/systemd/system/docker.service

重载unit配置文件

systemctl daemon-reload

启动Docker

systemctl start docker

设置开机自启

systemctl enable docker.service

查看Docker状态

systemctl status docker

 

 

卸载离线包安装的docker
停止docker

systemctl stop docker

删除相关文件

rm -rf /var/lib/docker
rm -rf /home/qw
cd /usr/bin && rm -rf containerd containerd-shim ctr docker dockerd docker-init docker-proxy runc
rm -rf /root/docker
rm -rf /etc/systemd/system/docker.service

重新加载配置文件

systemctl daemon-reload