docker 系列文章:
tar -zxvf docker-26.1.0.tgz

cp ./docker/* /usr/bin
# 进入 /etc/systemd/system/ 目录
cd /etc/systemd/system/
# 创建 docker.service
touch docker.service

# 编辑 docker.service
vim docker.service
将下边内容复制到docker.service。
注意,将其中的ip地址,改成您的服务器地址,其它参数不用改。
–insecure-registry=192.168.10.1
[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.10.1
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
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
systemctl status docker

systemctl enable docker.service
创建 docker.service 文件
在 docker-26.1.0.tgz同目录下 ,创建上文内容的 docker.service 文件
新建安装脚本文件 docker-install.sh
touch docker-install.sh
编辑docker-install.sh,内容如下
#!/bin/sh
echo '解压tar包'
tar -xvf $1
echo '将docker目录下所有文件复制到/usr/bin目录'
cp docker/* /usr/bin
echo '将docker.service 复制到/etc/systemd/system/目录'
cp docker.service /etc/systemd/system/
echo '添加文件可执行权限'
chmod +x /etc/systemd/system/docker.service
echo '重新加载配置文件'
systemctl daemon-reload
echo '启动docker'
systemctl start docker
echo '设置开机自启'
systemctl enable docker.service
echo 'docker安装成功'
docker -v
touch docker-uninstall.sh
编辑 docker-uninstall.sh,内容如下
#!/bin/sh
echo '停止docker'
systemctl stop docker
echo '删除docker.service'
rm -f /etc/systemd/system/docker.service
echo '删除docker文件'
rm -rf /usr/bin/docker*
echo '重新加载配置文件'
systemctl daemon-reload
echo '卸载成功'
chmod +x docker-install.sh
chmod +x docker-uninstall.sh
sh docker-install.sh docker-26.1.0.tgz
systemctl status docker
