Docker Installation#
Install on CentOS#
Prerequisites#
To install Docker Engine, you need a maintained version of CentOS 7
Installation methods#
Install using the repository#
sudo yum install -y yum-utils
#yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Install Docker Engine
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Or:
sudo yum install -y docker-ce docker-ce-cli containerd.io
Or:
sudo yum install -y --allowerasing docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
docker run hello-world
sudo systemctl stop docker
# Specific version
sudo yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-buildx-plugin docker-compose-plugin
Install from a package#
#curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
curl https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
yum install https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
Uninstall Docker Engine#
yum remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
Tips#
CentOS 8 Errors:
Problem 1: problem with installed package podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64
Problem 2: problem with installed package buildah-1.9.0-5.module_el8.1.0+237+63e26edc.x86_64
rpm -q podman
sudo dnf remove podman
rpm -q buildah
sudo dnf remove buildah
sudo systemctl enable docker
sudo mkdir /etc/docker
sudo vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"],
"log-driver": "json-file",
"log-opts": {"max-size":"500m", "max-file":"3"}
}
sudo systemctl daemon-reload
sudo systemctl restart docker
Util#
#停止所有容器
docker stop $(docker ps -aq)
Docker Registry#
docker.io: Docker Hub 官方镜像仓库
gcr.io、k8s.gcr.io: 谷歌镜像仓库
quay.io: Red Hat 镜像仓库
ghcr.io: GitHub 镜像仓库