A colleague today asked me to help him completely uninstall Docker from a specific host and reinstall it. The key challenge was finding the installation scripts and mirror sources for Docker and Docker Compose.
It turned out that this wasn't necessary. When I previously installed it on Ubuntu, I needed to access the corresponding GitHub bash script, and I used the Tsinghua University mirror for the installation at that time. However, installing directly on CentOS is not slow, largely thanks to the configuration of the CentOS software repositories.
Clean Uninstall
Be cautious that someone else may also be using docker to keep services running. If this occurs, communicate with them first to determine whether it is safe to stop the service for the relevant uninstallation operations.
docker ps # 没有服务则进行卸载, 有则进一步沟通
cat /etc/os-release # 查看系统发布版本 这里发现是 centos
# https://docs.docker.com/engine/install/centos/
# 安装时有删除干净的相关操作
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
If it is Ubuntu, then
# https://docs.docker.com/engine/install/debian/
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Install using the apt repository
# https://docs.docker.com/engine/install/debian/#install-using-the-repository
# Add Docker's official GPG key:
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
# Add the repository to Apt sources:
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
sudo apt-get update
The above process is relatively smooth when external internet access is available. Without external access, use a domestic mirror source, such as Tsinghua University's.
# https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/
export DOWNLOAD_URL="https://mirrors.tuna.tsinghua.edu.cn/docker-ce"
# 如您使用 curl
curl -fsSL https://get.docker.com/ | sh
# 如您使用 wget
wget -O- https://get.docker.com/ | sh
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done
apt-get update
apt-get install ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | 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://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Installation and Testing
# https://docs.docker.com/engine/install/centos/#set-up-the-repository
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo docker run hello-world
sudo docker compose version
镜像加速