Install Docker in CentOS

Before you install Docker CE for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.


  1. Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
    $ sudo yum install -y yum-utils \
      device-mapper-persistent-data \
  2. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
    $ sudo yum-config-manager \
        --add-repo \


    1. Install the latest version of Docker CE, or go to the next step to install a specific version:
      $ sudo yum install docker-ce
    2. To install a specific version of Docker CE, list the available versions in the repo, then select and install:a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:
      $ yum list docker-ce --showduplicates | sort -r
      docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable

      The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the .el7suffix in this example).

      b. Install a specific version by its fully qualified package name, which is the package name (docker-ce) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (-), for example, docker-ce-18.03.0.ce.

      $ sudo yum install docker-ce-

      Docker is installed but not started. The docker group is created, but no users are added to the group.

    3. Start Docker.
      $ sudo systemctl start docker
    4. Verify that docker is installed correctly by running the hello-world image.
      $ sudo docker run hello-world

      This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s