Install docker CE on June 22, 2021

Posted by dakkonz on Sun, 02 Jan 2022 23:29:14 +0100

Install docker CE

Docker supports the following 64 bit CentOS versions:

CentOS 7
CentOS 8
 Later version...
  • Automatic installation using official installation script

The installation commands are as follows:

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

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

curl -sSL https://get.daocloud.io/docker | sh
  • Manual installation

Uninstall old version

The older version of docker is called docker or docker engine. If you have installed these programs, 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

Use Docker warehouse for installation

Before installing Docker engine community on the new host for the first time, the Docker warehouse needs to be set. After that, you can install and update Docker from the warehouse.

Set up warehouse

Install the required 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.

Use the official source address (relatively slow)

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

You can select some domestic source addresses:
Alibaba cloud

$ 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 go to the next step to install a specific version:

$ sudo yum install docker-ce docker-ce-cli containerd.io
If you are prompted to accept the GPG key, select Yes.

There are multiple Docker Warehouse?
  • If multiple Docker warehouses are enabled, then yum install or yum update is not available
    If the version is specified in the command, the installation or update will always install the highest version, which may not be suitable for your stability needs.
  • Docker is not started by default after installation. 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, list the available versions in the repository, and then select and install:

1. Lists and sorts 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: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

2. Install a specific version through its complete package name, which is the package name (docker CE) plus the version string (second column), from the first colon (:) to the first hyphen, separated by a hyphen (-). 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

Verify that docker engine community is installed correctly by running the Hello world image.

$ sudo docker run hello-world

Uninstall docker

To delete an installation package:

yum remove docker-ce

Delete images, containers, configuration files, etc.:

rm -rf /var/lib/docker

Topics: Docker Container