注:
二进制包,与脚本在同级
目录
docker 离线安装:
docker_install.sh:
#!/bin/bash
# 指定 Docker 版本和文件名
DOCKER_VERSION="24.0.7"
DOCKER_FILENAME="docker-${DOCKER_VERSION}.tgz"
# 解压缩 Docker 二进制文件
tar -xzf docker-24.0.7.tgz
# 复制 Docker 二进制文件到 /usr/bin 目录
sudo cp docker/* /usr/bin/
# 创建 Docker 服务文件
sudo tee /etc/systemd/system/docker.service << EOF
[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 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
# 重新加载 systemd 配置
sudo systemctl daemon-reload
# 启动 Docker 服务
sudo systemctl start docker
# 设置 Docker 服务开机启动
sudo systemctl enable docker
echo "Docker安装结束"
docker_remove.sh
#!/bin/bash
# 删除 docker
sudo systemctl stop docker
sudo systemctl disable docker
sudo rm -rf /etc/systemd/system/docker.service
sudo rm -rf /usr/bin/docker*
sudo rm -rf /usr/bin/containerd*
sudo rm -rf /var/run/docker*
sudo rm -rf /var/lib/docker*
sudo rm -rf /var/lib/containerd*
echo "Docker卸载结束"
docker-compose 离线安装:
docker-compose_install.sh
#!/bin/bash
sudo cp docker-compose-linux-x86_64 /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose -v
echo '安装结束'
docker-compose_remove.sh
#!/bin/bash
sudo rm -rf /usr/local/bin/docker-compose
echo '卸载结束'