Install Docker on CentOS

Install Docker on CentOS

Docker’s CentOS-specific installation instructions are always going to be the most up to date for the latest version of Docker. However, the following recommendations and instructions should make it easier to manage the Docker installation over time and mitigate several known issues with various other configurations.

Recommendations

In addition to the general Docker requirements and recommendations for DC/OS, the following CentOS-specific recommendations will improve your DC/OS experience.

  • Use Docker’s yum repository to install Docker on CentOS. The yum repository makes it easy to upgrade and automatically manages dependency installation.

  • Prefer the OverlayFS storage driver. OverlayFS avoids known issues with devicemapper in loop-lvm mode and allows containers to use docker-in-docker, if they want.

  • Use CentOS 7.2 or greater. OverlayFS support was improved in 7.2 to fix a bug with XFS.

  • Format node storage as XFS. As of CentOS 7.2, “only XFS is currently supported for use as a lower layer file system“.

Instructions

The following instructions demonstrate how to use Docker with OverlayFS on CentOS 7.

  1. Verify that the kernel is at least 3.10:

    $ uname -r
    3.10.0-327.10.1.el7.x86_64
    
  2. Enable OverlayFS:

    $ sudo tee /etc/modules-load.d/overlay.conf <<-'EOF'
    overlay
    EOF
    
  3. Reboot to reload kernel modules:

    $ reboot
    
  4. Verify that OverlayFS is enabled:

    $ lsmod | grep overlay
    overlay
    
  5. Configure yum to use the Docker yum repo:

    $ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
    [dockerrepo]
    name=Docker Repository
    baseurl=https://yum.dockerproject.org/repo/main/centos/7/
    enabled=1
    gpgcheck=1
    gpgkey=https://yum.dockerproject.org/gpg
    EOF
    
  6. Configure systemd to run the Docker Daemon with OverlayFS:

    $ sudo mkdir -p /etc/systemd/system/docker.service.d && sudo tee /etc/systemd/system/docker.service.d/override.conf <<- 'EOF'
    [Service]
    ExecStart=
    ExecStart=/usr/bin/docker daemon --storage-driver=overlay -H fd://
    EOF
    
  7. Install the Docker engine, daemon, and service.

    Important: Docker version 1.12.x is not supported.

    $ sudo yum install -y docker-engine-1.11.2
    $ sudo systemctl start docker
    $ sudo systemctl enable docker
    

    When the process completes, you should see:

    Complete!
    Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
    
  8. Test that Docker is properly installed:

     $ sudo docker ps
    

For more generic Docker requirements, see System Requirements: Docker.