Note: Make sure your Linux system kernel version is higher than 3.10, and the system is 64-bit, in order to experience Docker.
Docker supports the following 64-bit CentOS versions:
The centos-extras library must be enabled. By default, this repository is enabled, but if it has been disabled, you need to re-enable it.
It is recommended to use overlay2 storage driver.
The older version of Docker is called docker or docker-engine. If these programs are already installed, please uninstall them and related dependencies.
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
This article uses centos 7.4
yum install -y vim wget epel-release
Before installing Docker Engine-Community on the new host for the first time, you need to set up the Docker repository. After that, you can install and update Docker from the repository.
Set up warehouse
Install the required software packages. yum-utils provides yum-config-manager, and the device mapper storage driver requires device-mapper-persistent-data and lvm2.
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
Use the following command to set up a stable warehouse.
sudo yum-config-manager \
- - add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
Install the latest version of Docker Engine-Community and containerd, or go to the next step to install a specific version:
sudo yum install -y docker-ce docker-ce-cli containerd.io
If you are prompted to accept the GPG key, select Yes.
Are there multiple Docker repositories?
If multiple Docker repositories are enabled, if the version is not specified in the yum install or yum update command, the installation or update will always install the highest version, which may not suit your stability requirements.
Docker is not started by default after installation. And the docker user group has been created, but there are no users under this user group.
To install a specific version of Docker Engine-Community, please list the available versions in the repository, then select and install:
1、 List and sort the versions available in your repository. This example sorts the results by version number (from high to low).
yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 @docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
...
2、 Install a specific version by its full package name, which is the package name (docker-ce) plus the version string (second column), from the first colon (:) all the way to the first hyphen , And separated by a hyphen (-). For example: docker-ce-19.03.4.
sudo yum install -y docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
E.g:
yum install -y docker-ce-19.03.5-3.el7 docker-ce-cli-19.03.5-3.el7 containerd.io
Start Docker.
sudo systemctl start docker
Run the hello-world image to verify that Docker Engine-Community is installed correctly.
sudo docker run hello-world
Increase configuration
sudo tee /etc/docker/daemon.json <<-'EOF'{"registry-mirrors":["http://hub-mirror.c.163.com"]}
EOF
Restart docker
sudo systemctl restart docker
Install docker command completion tool
yum install -y bash-completion
Note: After the installation is complete, you must log out of the user, log in again, and that's it
Set docker to start automatically
systemctl enable docker
Reference link for this article:
https://www.runoob.com/docker/centos-docker-install.html
Recommended Posts