How to install Docker on Centos7


Main Reference from official docker website: installation on Centos


Docker requires a 64-bit installation regardless of your CentOS version. Also, your kernel must be 3.10 at least, which CentOS 7 runs.


$ uname -r

Finally, it is recommended that you fully update your system. Please keep in mind that your system should be fully patched to fix any potential kernel bugs. Any reported kernel bugs may have already been fixed on the latest kernel packages.

Install with yum

  2. Make sure your existing yum packages are up-to-date.
    $ sudo yum update
  3. Add the yum repo.
    $ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
    name=Docker Repository
  4. Install the Docker package.
    $ sudo yum install docker-engine
  5. Start the Docker daemon.
    $ sudo service docker start
  6. Verify docker is installed correctly by running a test image in a container.
    $ sudo docker run hello-world
    Unable to find image 'hello-world:latest' locally
        latest: Pulling from hello-world
        a8219747be10: Pull complete
        91c95931e552: Already exists
        Digest: sha256:aa03e5d0d5553b4c3473e89c8619cf79df368babd1.7.1cf5daeb82aab55838d
        Status: Downloaded newer image for hello-world:latest
        Hello from Docker.
        This message shows that your installation appears to be working correctly.
        To generate this message, Docker took the following steps:
         1. The Docker client contacted the Docker daemon.
                (Assuming it was not already locally available.)
                executable that produces the output you are currently reading.
                to your terminal.
         $ docker run -it ubuntu bash
        For more examples and ideas, visit:

Create a docker group

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can reach it with sudo. For this reason, docker daemon always runs as the root user.



To create the docker group and add your user:

  1. Log into Centos as a user with sudo privileges.
  2. Create the docker group.sudo groupadd docker
  3. Add your user to docker group.sudo usermod -aG docker your_username
  5. Verify your work by running docker without sudo.
    $ docker run hello-world

Start the docker daemon at boot

To ensure Docker starts when you boot your system, do the following:

  $ sudo chkconfig docker on

If you need to add an HTTP Proxy, set a different directory or partition for the Docker runtime files, or make other customizations, read our Systemd article to learn how to customize your Systemd Docker daemon options.

Leave a Reply
