CentOS Docker Installation

CentOS Docker Installation

Docker supports the following 64-bit versions of CentOS.

  • CentOS 7
  • CentOS 8
  • Higher versions…

Automatically install Docker 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 daocloud one-click install command at –

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

Install Docker manually

Uninstall an older version

Older versions of Docker are called docker or docker-engine. If these are already installed, uninstall them and the associated dependencies.

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

Installing Docker Engine-Community

Installing with a Docker repository

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

Setting up the repository

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 repository.

Use the official source address

$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/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: ### Install Docker Engine-Community

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

If you are prompted to accept GPG keys, select Yes.

Have multiple Docker repositories?

If multiple Docker repositories are enabled, installations or updates performed without specifying a version in the yum install or yum update commands will always install the highest version, which may not be suitable for your stability needs.

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

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

  1. List and sort the versions available 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
  1. Install 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 (:) all the way 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 the Docker Engine-Community is correctly installed by running the hello-world image.

$ sudo docker run hello-world

Uninstall docker

To remove the installation package.

yum remove docker-ce

Remove images, containers, configuration files, etc.

rm -rf /var/lib/docker
Like(0)