Docker is a platform that makes it easy to build, deploy and start applications using containers. Developing with Docker also speeds up applications because it shares the kernel and other Linux resources.
In this guide we will see how to install docker on CentOS 7.
Uninstall old Docker versions :
Make sure no docker version is installed on your OS by typing the dnf command below :
[root@docker ~]# sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine Loaded plugins: fastestmirror No Match for argument: docker No Match for argument: docker-client No Match for argument: docker-client-latest No Match for argument: docker-common No Match for argument: docker-latest No Match for argument: docker-latest-logrotate No Match for argument: docker-logrotate No Match for argument: docker-engine No Packages marked for removal
Update the system :
[root@docker ~]# yum update -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile base: mirror.marwan.ma extras: repo.nixval.com updates: mirror.marwan.ma Resolving Dependencies --> Running transaction check ---> Package bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.4 will be updated ---> Package bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.5 will be an update ---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.4 will be updated ---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update ---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.4 will be updated ---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be an update ---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.4 will be updated ---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update ---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.4 will be updated ---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update ---> Package firewalld.noarch 0:0.6.3-12.el7 will be updated ---> Package firewalld.noarch 0:0.6.3-13.el7_9 will be an update ---> Package firewalld-filesystem.noarch 0:0.6.3-12.el7 will be updated
Installer les dépendances :
The next step is to install the dependencies required to install docker :
[root@docker ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile base: mirror.marwan.ma extras: repo.nixval.com updates: mirror.marwan.ma Package device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 already installed and latest version Package 7:lvm2-2.02.187-6.el7_9.5.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch --> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch --> Running transaction check ---> Package libxml2-python.x86_64 0:2.9.1-6.el7.5 will be installed ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch --> Running transaction check ---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed --> Finished Dependency Resolution
Add docker repository
To install docker, you must first add the docker repository with the command below :
[root@docker ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo Loaded plugins: fastestmirror adding repo from: https://download.docker.com/linux/centos/docker-ce.repo grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo
You can see that the repository has been installed correctly :
[root@docker ~]# ll /etc/yum.repos.d/ total 44 -rw-r--r--. 1 root root 1664 Nov 23 10:08 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Nov 23 10:08 CentOS-CR.repo -rw-r--r--. 1 root root 649 Nov 23 10:08 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Nov 23 10:08 CentOS-fasttrack.repo -rw-r--r--. 1 root root 8515 Nov 23 10:08 CentOS-Vault.repo -rw-r--r--. 1 root root 616 Nov 23 10:08 CentOS-x86_64-kernel.repo -rw-r--r--. 1 root root 1919 Apr 12 07:33 docker-ce.repo
Installation :
We can finally install docker with the command below :
[root@docker ~]# yum install docker
Once installed, start docker and put the service in status enabled :
[root@docker ~]# systemctl start docker.service [root@docker ~]# systemctl enable docker
Install a specific version of docker :
First, list the versions available with the command below :
[root@docker ~]# yum list docker-ce --showduplicates | sort -r updates: mirror.marwan.ma This system is not registered with an entitlement server. You can use subscription-manager to register. : manager Loading mirror speeds from cached hostfile Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription- extras: repo.nixval.com docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.5-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 docker-ce.x86_64 3:19.03.15-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.14-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.13-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
This command displays the versions available on the repository we have installed.
yum install docker-ce-<VERSION STRING>
Example :
[root@docker ~]# yum install docker-ce-17.06.2.ce
Docker test :
Check that docker has been installed correctly with the command below :
[root@docker ~]# docker run hello-world Unable to find image 'hello-world:latest' locally Trying to pull repository docker.io/library/hello-world latest: Pulling from docker.io/library/hello-world b8dfde127a29: Pull complete Digest: sha256:f2266cbfc127c960fd30e76b7c792dc23b588c0db76233517e1891a4e357d519 Status: Downloaded newer image for docker.io/hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: The Docker client contacted the Docker daemon. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
Migrer CentOS 7 vers Rocky Linux 9
7zip: 9 Commandes utiles de les plus utilisés
Comment installer Docker sur Rocky Linux 9
mkfs : Création des systèmes de fichier
Fail2Ban : How to protect Linux services