[TOC]
Introduce the process of installing docker in the CentOS operating system. For the installation method of docker in other Linux distributions, please refer to the official installation tutorial.
1. Prerequisites
First make sure that you are CentOS7 and above. According to the official documentation, the minimum operating system version requirement for installing docker ce is CentOS7, and CentOS6 is no longer supported. (March 30, 2022)
# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
Check the operating system kernel version, which is required to be a version above 3.10
# uname -r
3.10.0-1160.el7.x86_64
If there is an old docker installation version, remove the old version first (if it has not been installed, it does not hurt to execute this command)
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
Install some necessary system tools: yum-utils contains yum-config-manager (will be used later), device-mapper-persistent-data and lvm2 contain storage drivers required by docker devicemapper.
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
2. Update software source information
Add software source information, it is recommended to use Alibaba Cloud software source, the domestic download speed is faster.
- Docker official recommended software source
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- Alibaba Cloud Software Source
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Update yum cache:
sudo yum makecache fast
3. Install Docker-CE
Since March 2017, docker has derived two branch versions: Docker CE and Docker EE.
- Docker CE is the community free edition,
- Docker EE is the enterprise version, which is more secure, but requires payment
The following describes the installation of Docker CE. Unless your enterprise provides external container services, Docker CE is sufficient for internal enterprise applications.
sudo yum -y install docker-ce;
The command to manage the Docker service, after the installation is complete, execute the command to start the Docker service.
sudo systemctl start docker; #启动
sudo systemctl restart docker; #重启
sudo systemctl stop docker; #停止
After the installation is successful, you can view the docker service installation information by viewing
docker version
Validation test, run the hello-world image (start the container) from the command line to verify that docker CE is installed correctly.
sudo docker run hello-world
If the installation is correct and running the hello world image will produce the following information:
4. Uninstall Docker CE
Execute the following command to delete Docker CE, /var/lib/docker
The directory saves the image, storage, and container-related information of the container running. You can delete it if necessary.
yum remove docker-ce;
yum remove docker-ce-cli;
rm -rf /var/lib/docker;
rm -fR /var/run/docker;
rm -f /var/run/docker.sock
Welcome to pay attention to my announcement number: Antetokounmpo, reply 003 and present the PDF version of the column "The Way of Docker Cultivation" where this article is located, and more than 30 excellent docker articles. Antetokounmpo Blog: zimug.com
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。