docker-ce离线安装
1、最优方案,下载官网提供的包来安装。
1)下载地址:
docker下载地址:https://download.docker.com/linux/static/stable/
docker-compose下载地址:https://github.com/docker/compose/releases
2)解压安装:以x86架构下的docker 24.0.9和docker-compose v2.27.3为例:
wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.9.tgz wget https://github.com/docker/compose/releases/download/v2.27.3/docker-compose-linux-x86_64 tar -zxvf docker-24.0.9.tgz mv docker/* /usr/bin/ -f mv docker-compose-linux-x86_64 /usr/bin/docker-compose -f chmod +x /usr/bin/docker-compose
3)配置docker.service
vi /usr/lib/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 --default-ulimit nofile=65535:65535 ExecReload=/bin/kill -s HUP $MAINPID TimeoutStartSec=0 RestartSec=2 Restart=always StartLimitBurst=3 StartLimitInterval=60s LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Delegate=yes KillMode=process [Install] WantedBy=multi-user.target
执行:
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
2、docker离线安装的方式基本就是准备rpm包安装即可。
3、准备的rpm包有:
container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm containerd.io-1.6.8-3.1.el7.x86_64.rpm device-mapper-1.02.170-6.el7_9.5.x86_64.rpm device-mapper-event-1.02.170-6.el7_9.5.x86_64.rpm device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64.rpm device-mapper-libs-1.02.170-6.el7_9.5.x86_64.rpm device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64.rpm docker-ce-19.03.15-3.el7.x86_64.rpm docker-ce-cli-19.03.15-3.el7.x86_64.rpm lvm2-2.02.187-6.el7_9.5.x86_64.rpm lvm2-libs-2.02.187-6.el7_9.5.x86_64.rpm yum-utils-1.1.31-54.el7_8.noarch.rpm
4、下载方式:安装需要的包参考:https://developer.aliyun.com/mirror/docker-ce
新方式:
# 更新源地址 sudo yum install -y yum-utils device-mapper-persistent-data lvm2 sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo sudo yum makecache fast
# 下载离线包 yumdownloader --resolve docker-ce-24.0.9 docker-ce-cli-24.0.9
# 离线安装 yum -y localinstall *.rpm
老方式:
yum install --downloadonly --downloaddir=/tmp <package-name>
yum -y localinstall *.rpm
6、安装命令
rpm -ivh *.rpm
7、查询和卸载命令
rpm -qa| grep <name>
rpm -e --nodeps <query-result>