English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CentOS Docker Installation

Docker supports the following 64 For CentOS version:

  • CentOS 7

  • CentOS 8

  • Higher version...

Install automatically using the official installation script

The installation command is as follows:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

You can also use the one-click installation command of domestic daocloud:

curl -SSL https://get.daocloud.io/docker | sh

Manual Installation

Uninstall the old version

Older Docker versions are called docker or docker-engine. If these programs are already installed, please uninstall them and their related dependencies.

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

Install Docker Engine-Community

Install using the Docker repository

First install Docker Engine on a new host-Before Community, you need to set up the Docker repository. After that, you can install and update Docker from the repository.

Set up the repository

install the required software packages. yum-utils provides yum-config-manager , and the device mapper storage driver needs 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 repository.

Use the official source address (slower)

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

You can choose some domestic source addresses:

Aliyun

$ sudo yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Tsinghua University Source

$ sudo yum-config-manager \
    --add-repo \
    https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo

Install Docker Engine-Community

Install the latest version of Docker Engine-Community and containerd, or proceed to the next step to install a specific version:

$ sudo yum install docker-ce docker-ce-cli containerd.io

If prompted to accept the GPG key, please select Yes.

Do you have multiple Docker repositories?

If multiple Docker repositories are enabled, installations or updates without specifying a version in the yum install or yum update command will always install the highest version, which may not meet your stability requirements.

Docker is not started by default after installation, and the docker user group has been created, but there is no user under this group.

To install a specific version of Docker Engine-Please list the available versions in the repository and then select and install:

1List and sort the available versions in your repository. This example sorts the results by version number (from highest to lowest).

$ 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

2Install 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 (:) to the first hyphen, and use the hyphen (-separated. For example: docker-ce-18.09.1.

$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

Start Docker.

$ sudo systemctl start docker

By running hello-Verify that Docker Engine is correctly installed by running the hello world image-Community .

$ sudo docker run hello-world