docker离线安装部署
下载资源包
shell
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.0.tgz
wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.6.tgz
安装
shell
#1、解压docker
tar -zxvf docker-24.0.6.tgz
#2、将解压之后的`docker`文件移到 `/usr/bin`目录下
cp docker/* /usr/bin/
#3、将`docker`注册成系统服务
vim /etc/systemd/system/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
#4、给文件增加可执行权限,加载配置
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
#5、启动docker
systemctl start docker
#6、设置开启启动
systemctl enable docker.service
docker离线模式卸载
shell
# 停止docker
systemctl stop docker
# 移除开机自启动
systemctl disable docker.service
# 删除service服务
rm -f /etc/systemd/system/docker.service
# 删除Docker相关命令
rm -f /usr/bin/docker*
rm -f /usr/bin/containerd*
rm -f /usr/bin/ctr
rm -f /usr/bin/runc
# 删除docker目录和容器相关文件
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
docker存储目录修改
shell
# 编辑配置文件
vim /etc/docker/daemon.json
{
#默认位:/var/lib/docker
"data-root": "/data/var/lib/docker"
}
# 加载配置
systemctl daemon-reload
ok不ok。