linux下离线安装与卸载docker

安装

下载压缩包
docker压缩包下载,下载的版本
tar -xvf docker-20.10.9.tgz
下载后上传到服务器

创建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

解压

tar -xvf  docker-20.10.9.tgz

docker目录复制到/usr/bin目录下

cp docker/* /usr/bin/

docker.service 复制到/etc/systemd/system/ 目录下

cp docker.service /etc/systemd/system/

添加文件权限

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

重启

systemctl daemon-reload
systemctl start docker

设置开机自启

systemctl enable docker.service

docker -v
在这里插入图片描述

卸载

删除docker.service

rm -f /etc/systemd/system/docker.service

删除docker文件

rm -rf /usr/bin/docker*

重新加载配置文件

systemctl daemon-reload

docker -v
在这里插入图片描述


版权声明:本文为weixin_42262081原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。