安装Docker Engine之二:Linux系统-Debian、RHEL、SLES、Fedora
Debian
内核版本
- Debian Bookworm 12 (stable)
- Debian Bullseye 11 (oldstable)
- 卸载老版本
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
- 配置apt仓库
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
安装指定版本的Docker Engine
- 更新apt仓库索引
sudo apt-get update
- 列出docker版本号
apt-cache madison docker-ce | awk '{ print $3 }'
- 安装指定版本
VERSION_STRING=5:24.0.0-1~debian.11~bullseye sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
- 启动docker
sudo service docker start
- 运行docker容器
sudo docker run hello-world
RHEL
内核版本:
- RHEL 7 on s390x (IBM Z)
- RHEL 8 on s390x (IBM Z)
- RHEL 9 on s390x (IBM Z)
- 卸载老版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine \
podman \
runc
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
- 配置仓库
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
- 列出docker版本
yum list docker-ce --showduplicates | sort -r
- 安装指定版本
VERSION_STRING=docker-ce-3:24.0.0-1.el8
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-buildx-plugin docker-compose-plugin
- 启动docker
sudo systemctl start docker
- 运行hello-world容器
sudo docker run hello-world
SLES
内核版本
- SLES 15-SP3 on s390x (IBM Z)
- SLES 15-SP4 on s390x (IBM Z)
- 根据内核版本配置OpenSUSE SELinux仓库
SLES 15-SP3
opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/SLE_15_SP3/security:SELinux.repo"
sudo zypper addrepo $opensuse_repo
SLES 15-SP4
opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/15.4/security:SELinux.repo"
sudo zypper addrepo $opensuse_repo
- 卸载老版本
sudo zypper remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine \
runc
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
- 配置仓库
sudo zypper addrepo https://download.docker.com/linux/sles/docker-ce.repo
- 列出docker版本
sudo zypper search -s --match-exact docker-ce | sort -r
- 安装指定版本(VERSION_STRING的格式 “docker-ce-” + $版本列表中的第二列)
VERSION_STRING=docker-ce-3:24.0.0
sudo zypper install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-buildx-plugin docker-compose-plugin
- 启动docker
sudo systemctl start docker
- 运行hello-world容器
sudo docker run hello-world
Fedora
内核版本
- Fedora 37
- Fedora 38
- 卸载老版本
sudo dnf remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
- 配置仓库
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
- 列出docker版本
dnf list docker-ce --showduplicates | sort -r
- 安装指定版本(VERSION_STRING的格式 “docker-ce-” + $版本列表中的第二列)
VERSION_STRING=docker-ce-3:24.0.0-1.fc37
sudo dnf -y install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-buildx-plugin docker-compose-plugin
- 启动docker
sudo systemctl start docker
- 运行hello-world容器
sudo docker run hello-world