Configuring Docker

Use this procedure to configure Docker.
  1. Log in to the delegate host as root, or as a user with superuser privileges.
  2. Create a symbolic link for the Docker temporary directory.
    Docker uses its temporary directory to spool images. The default directory is /var/lib/docker/tmp. The following command specifies the same directory that Control Center uses, /tmp. You can specify any directory that has a minimum of 10GB of unused space.
    1. Create the docker directory in /var/lib.
      mkdir /var/lib/docker
    2. Create the link to /tmp.
      ln -s /tmp /var/lib/docker/tmp
  3. Create a systemd drop-in file for Docker.
    1. Create the override directory.
      mkdir -p /etc/systemd/system/docker.service.d
    2. Create the unit drop-in file.
      cat <<EOF > /etc/systemd/system/docker.service.d/docker.conf
      ExecStart=/usr/bin/dockerd \$OPTIONS
    3. Reload the systemd manager configuration.
      systemctl daemon-reload
  4. Create an LVM thin pool for Docker data.
    For more information about the serviced-storage command, see serviced-storage.
    To use an entire block device or partition for the thin pool, replace Device-Path with the device path:
    serviced-storage create-thin-pool docker Device-Path
    On success, the result is the device mapper name of the thin pool, which always starts with /dev/mapper.
  5. Configure and start the Docker service.
    1. Create a variable for the name of the Docker thin pool.

      Replace Thin-Pool-Device with the name of the thin pool device created in the previous step:

    2. Create variables for adding arguments to the Docker configuration file. The --exec-opt argument is a workaround for a Docker issue on RHEL/CentOS 7.x systems.
      myDriver="--storage-driver devicemapper"
      myFix="--exec-opt native.cgroupdriver=cgroupfs"
      myMount="--storage-opt dm.mountopt=discard"
      myFlag="--storage-opt dm.thinpooldev=$myPool"
    3. Add the arguments to the Docker configuration file.
      echo 'OPTIONS="'$myLog $myDriver $myFix $myMount $myFlag'"' \
        >> /etc/sysconfig/docker
    4. Start or restart Docker.
      systemctl restart docker
      The startup may take up to a minute, and may fail. If startup fails, repeat the restart command.
  6. Configure name resolution in containers.
    Each time it starts, docker selects an IPv4 subnet for its virtual Ethernet bridge. The selection can change; this step ensures consistency.
    1. Identify the IPv4 subnet and netmask docker has selected for its virtual Ethernet bridge.
      ip addr show docker0 | grep inet
    2. Open /etc/sysconfig/docker in a text editor.
    3. Add the following flags to the end of the OPTIONS declaration.

      Replace Bridge-Subnet with the IPv4 subnet docker selected for its virtual bridge:

      --dns=Bridge-Subnet --bip=Bridge-Subnet/16
      For example, if the bridge subnet is, add the following flags:
      --dns= --bip=
    4. Save the file, and then close the editor.
    5. Restart the Docker service.
      systemctl restart docker 
Proceed to the next chapter and configure the host.