Preface
Docker is used more and more, and the installation is very simple. This time I will record the basic steps.
Docker currently supports CentOS 7 and later versions, and the kernel requirement is at least 3.10.
There are installation steps on the Docker official website, this article is just for recording, you can also refer to Get Docker CE for CentOS
CentOS 7(Minimal Install)
$ cat /etc/redhat-release
CentOS Linux release 7.6.1810(Core)
Docker can be installed after CentOS 7, and you can also confirm it.
$ uname -a
Linux localhost.localdomain 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 2914:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Docker needs to use the source centos-extra
. If you close it, you need to restart it. You can refer to Available Repositories for CentOS.
The old version of Docker is called docker
or docker-engine
. If you have installed the old version of Docker, you need to uninstall it.
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
The content of the old version is under /var/lib/docker
, and the images, containers, volumes, and networks in the directory can all be retained.
Docker CE package, the current package name is docker-ce
.
To facilitate the addition of software sources and support the devicemapper storage type, install the following software packages
$ sudo yum update
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
Add Docker stable version of yum software source
$ sudo yum-config-manager \
- - add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
Update the cache of yum software source and install Docker.
$ sudo yum update
$ sudo yum install docker-ce
If the GPG key receiving prompt pops up, please confirm whether it is 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
, if so, you can accept and continue the installation.
At this point, Docker has been installed, the Docker service is not started, the docker group in the operating system is created, but no users are in this group.
Note
The default docker group has no users (that is, you need to use sudo to use the docker command).
You can add users to the docker group (this user can directly use the docker command).
Join docker user group command
$ sudo usermod -aG docker USER_NAME
After the user updates the group information, log in to the system again to take effect.
If you want to install a specific version of Docker, you can check the version and install it.
$ yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
You can specify the version to install, the version number can be ignored :
and el7
, such as docker-ce-18.09.1
$ sudo yum install docker-ce-<VERSION STRING>
At this point, the specified version of Docker has been installed. Similarly, the docker service in the operating system is not started, only the docker group is created, and there are no users in the group.
If you want to add to boot
$ sudo systemctl enable docker
Start the docker service
$ sudo systemctl start docker
Verify that the Docker CE installation is correct, you can run the hello-world
image
$ sudo docker run hello-world
Use yum to manage, update and uninstall are very convenient.
$ sudo yum update docker-ce
$ sudo yum remove docker-ce
Note that docker's local files, including images, containers, and storage volumes, need to be deleted manually. The default directory is stored in /var/lib/docker
.
$ sudo rm -rf /var/lib/docker
This article demonstrates the steps to install Docker CE in yum under CentOS 7.
Get Docker CE for CentOSAvailable Repositories for CentOS
Recommended Posts