安装
下载压缩包
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

该博客详细介绍了在服务器上安装Docker的完整流程,包括下载tar包、创建docker.service配置文件、设置文件权限、启动及设置开机自启等步骤。同时,也提供了卸载Docker的相应操作,包括删除服务文件和相关目录,以及重新加载配置文件。
899

被折叠的 条评论
为什么被折叠?



