docker - CentOS Docker installation

1, Automatic installation using official installation script

1. Installation command

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

2. You can also use the domestic daocloud one click installation command

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

2, Manual installation

1. Uninstall the 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

3, 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.
1. Use the official source address (relatively slow)
$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
2. Some domestic source addresses can be selected:

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 prompted to accept GPG Key, please select Yes.
Are there multiple Docker warehouses?

If multiple Docker warehouses are enabled, the installation or update will always install the highest version without specifying the version in the yum install or yum update command, 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

1. Delete the installation package:

yum remove docker-ce

2. Delete images, containers, configuration files, etc.:

rm -rf /var/lib/docker

Tags: Linux CentOS Docker

Posted on Mon, 25 Oct 2021 21:50:57 -0400 by fodder