Install Docker CE in yum under CentOS 7

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

Environmental description###

CentOS 7(Minimal Install)

$ cat /etc/redhat-release 
CentOS Linux release 7.6.1810(Core)

Ready to work##

Operating system requirements###

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.

Uninstall the old version###

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.

installation##

Installation preparation###

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 yum software source###

Add Docker stable version of yum software source

$ sudo yum-config-manager \
 - - add-repo \
 https://download.docker.com/linux/centos/docker-ce.repo

Install Docker

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.

Install the specified version###

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.

Start Docker

If you want to add to boot

$ sudo systemctl enable docker

Start the docker service

$ sudo systemctl start docker

Verify installation###

Verify that the Docker CE installation is correct, you can run the hello-world image

$ sudo docker run hello-world

Update and uninstall Docker

Use yum to manage, update and uninstall are very convenient.

Update Docker CE

$ sudo yum update docker-ce

Uninstall Docker CE

$ sudo yum remove docker-ce

Delete local files###

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

in conclusion##

This article demonstrates the steps to install Docker CE in yum under CentOS 7.

References##

Get Docker CE for CentOSAvailable Repositories for CentOS

Recommended Posts

Install Docker CE in yum under CentOS 7
CentOS 7 install Docker CE
Install MySql with Docker in CentOS7
Install and use docker under CentOS 6.8
Install Centos7 operating system in Docker
CentOS 7 install Docker
CentOS7 install Docker
Centos7 install Docker
Centos7 install docker18
centos7 install docker
CentOS 6 install Docker
Centos8 install Docker
Install Docker on Centos7
Centos7 YUM install MariaDB 10.0
Install MySQL5.7 in centos7
CentOS 7 install Docker service
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
CentOS 7.2 Yum install MySQL 5.6
Install redis5.0 in CentOS7
Install mysql under Centos 7
CentOS 8-dnf install docker
Install Jenkins under Centos 7
Centos7 YUM install MariaDB 10.0
Install mysql5.1 under CentOS6.5
install Docker on centos6.5
Install svn and configuration through yum under CentOS
How to install Docker CE on RHEL 8 / CentOS 8
Build docker environment under Centos6.5
Install Oracle11gR2 database under CentOS6.9
Install docker transfer on Centos7
Install MySQL under Linux (CentOS 7)
Install docker on Centos system
Install Java JDK8 under CentOS6
Install MongoDB database under CentOS7
CentOS 6.8 under linux install mongodb
CentOS 7 yum install PHP7.3 tutorial
Install Mesos tutorial under CentOS7
CentOS7 yum install and start mysql
Install and configure keepalived under CentOS 5.9
Install JDK8 in rpm on CentOS7
CentOS Yum compile and install MySQL 5.6
Compile and install LAMP under Centos 5.2
[Introduction to redis] Install redis under Centos
Minimal install JDK 1.8 tutorial in CentOS 7
How to install PHP7.4 in CentOS
Install Percona Server database (in CentOS 8)
Install and configure Docker in Ubuntu
CentOS7 yum install and start mysql
Install Harbor mirror warehouse under CentOS
Centos yum install mysql5.6 or above
Install Python3 and ansible under CentOS8
Install the latest OpenCV4.3 under Centos8
Installation of Docker CE under Ubuntu
Install and configure FreeIPA in Centos7
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
How to install Android SDK in centos7
Compile and install libmodbus library under CentOS7
CentOS yum install Apache + PHP + Tomcat7 + MySQL