The software described in this documentation is either no longer supported or is in extended support.
Oracle recommends that you upgrade to a current supported release.

2.1 Installing and Configuring the Docker Engine on Oracle Linux 6

Note

Docker version 1.9 and later require that you configure the system to use the Unbreakable Enterprise Kernel Release 4 (UEK R4) and boot the system with this kernel.

To install and configure the Docker Engine on an Oracle Linux 6 system:

  1. If you want to install Docker, configure the system to use the Unbreakable Enterprise Kernel Release 4 (UEK R4) and boot the system with this kernel:

    1. If your system is registered with ULN, disable access to the ol6_x86_64_UEKR3_latest or ol6_x86_64_UEK_latest channels and enable access to the ol6_x86_64_UEKR4 channel.

      If you use the Oracle Linux yum server, disable the ol6_UEKR3_latest repository and enable the ol6_UEKR4 repository in the repository configuration files in /etc/yum.repos.d/uek-ol6.repo, for example:

      [ol6_UEKR4]
      name=Latest Unbreakable Enterprise Kernel Release 4 for Oracle Linux $releasever ($basearch)
      baseurl=https://yum.oracle.com/repo/OracleLinux/OL6/UEKR4/$basearch/
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
      gpgcheck=1
      enabled=1
      
      [ol6_UEKR3_latest]
      name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
      baseurl=https://yum.oracle.com/repo/OracleLinux/OL6/UEKR3/latest/$basearch/
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
      gpgcheck=1
      enabled=0
      
      [ol6_UEK_latest]
      name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
      baseurl=https://yum.oracle.com/repo/OracleLinux/OL6/UEK/latest/$basearch/
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
      gpgcheck=1
      enabled=0
    2. Run the following command to upgrade the system to UEK R4:

      # yum update
    3. To ensure that UEK R4 is the default boot kernel, edit /boot/grub/grub.conf and change the value of the default directive to index the entry for the UEK R4 kernel. For example, if the UEK R4 kernel is the first entry, set the value of default to 0.

    4. Reboot the system, selecting the UEK R4 kernel if this is not the default boot kernel.

      # reboot
  2. If your system is registered with ULN, enable the ol6_x86_64_addons channel.

    If you use the Oracle Linux yum server, enable the ol6_addons repository in the repository configuration file at /etc/yum.repos.d/oracle-linux-ol6.repo, for example:

    [ol6_addons]
    name=Oracle Linux $releasever Add ons ($basearch)
    baseurl=https://yum.oracle.com/repo/OracleLinux/OL6/addons/$basearch/
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
    gpgcheck=1
    enabled=1
  3. Install the docker-engine package.

    # yum install docker-engine
  4. By default, the Docker Engine uses the device mapper as a storage driver to manage Docker containers. As with LXC, there are benefits to using the snapshot features of btrfs instead.

    Note

    Oracle recommends using btrfs because of the stability and maturity of the technology. If a new device for btrfs is not available, you should use overlay2 as the storage driver instead of devicemapper for performance reasons. You can configure overlay2 by adding the --storage-driver=overlay2 option to other_args in /etc/sysconfig/docker. The overlayfs file system is available with UEK R4.

    For more information, see https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/.

    To configure the Docker Engine to use btrfs instead of the device mapper:

    1. Use yum to install the btrfs-progs package.

      # yum install btrfs-progs

    2. Create a btrfs file system on a suitable device such as /dev/sdb in this example:

      # mkfs.btrfs /dev/sdb

      Note

      Any unused block device that is large enough to store several containers is suitable. The suggested minimum size is 1GB but you might require more space to implement complex Docker applications. If the system is a virtual machine, Oracle recommends that you create, partition, and format a new virtual disk. Alternatively, convert an existing ext3 or ext4 file system to btrfs. See https://docs.oracle.com/cd/E37670_01/E37355/html/ol_use_case7_btrfs.html in the Oracle Linux Administrator's Solutions Guide for Release 6. If an LVM volume group has available space, you can create a new logical volume and format it as a btrfs file system.

    3. Mount the file system on /var/lib/docker. On a fresh installation, you might need to create this directory first.

      # mkdir /var/lib/docker
      # mount /dev/sdb /var/lib/docker

      Important

      It is critical that you ensure that there is always available disk space in /var/lib/docker for all of the images and containers that you intend to run. If a running container fills /var/lib/docker, a restart of the Docker Engine fails with an error similar to the following:

      Error starting daemon: write /var/lib/docker/volumes/metadata.db:
      no space left on device 

      Without the Docker Engine running it becomes difficult to clean up or remove existing or obsolete images. If this happens, you can try to gain some space by removing the contents of /var/lib/docker/tmp. However, the best solution is to avoid reaching this situation by implementing quotas that prevent a scenario where the Docker Engine runs out of the disk space required to run.

    4. Add an entry for /var/lib/docker to the /etc/fstab file.

      /dev/sdb      /var/lib/docker    btrfs    defaults   0 0

  5. Edit /etc/sysconfig/docker to configure global networking options, for example:

    • If your system needs to use a web proxy to access the Docker Hub, add the following lines:

      export HTTP_PROXY="proxy_URL:port"
      export HTTPS_PROXY="proxy_URL:port"

      Replace proxy_URL and port with the appropriate URL and port number for your web proxy.

    • To configure IPv6 support in version 1.5 and later of Docker, add the --ipv6 option to OPTIONS, for example:

      OPTIONS="--ipv6"

      With IPv6 enabled, Docker assigns the link-local IPv6 address fe80::1 to the bridge docker0.

      If you want Docker to assign global IPv6 addresses to containers, additionally specify the IPv6 subnet to the --fixed-cidr-v6 option, for example:

      OPTIONS="--ipv6 -- fixed-cidr-v6='2001:db8:1::/64'"

    For more information about configuring Docker networking, see https://docs.docker.com/engine/userguide/networking/.

  6. In version 1.5 and later of Docker, the docker service unshares its mount namespace to resolve device busy issues with the device mapper storage driver. However, this configuration breaks autofs in the host system and prevents you from accessing subsequently mounted volumes in Docker containers. The workaround is to stop the Docker service from unsharing its mount namespace.

    Edit /etc/init.d/docker and remove the $unshare -m -- parameters from the line that starts the daemon. For example, change the line that reads similar to the following:

    "$unshare" -m -- $exec $other_args &>> $logfile &

    so that it reads:

    $exec $other_args &>> $logfile &
    Note

    You might need to reapply this workaround if you update the docker package and the change to /etc/init.d/docker is overwritten.

  7. Start the docker service and configure it to start at boot time:

    # service docker start
    # chkconfig docker on

Note

If you have installed the mlocate package, it is recommended that you modify the PRUNEPATHS entry in /etc/updatedb.conf to prevent updatedb from indexing directories below /var/lib/docker, for example:

PRUNEPATHS="/media /tmp /var/lib/docker /var/spool /var/tmp"

This entry prevents locate from reporting files that belong to Docker containers.

To check that the docker service is running, use the following command:

# service docker status
docker (pid  1958) is running...

You can also use the docker command to display information about the configuration and version of the Docker Engine, for example:

# docker info
Containers: 0
Images: 6
Storage Driver: btrfs
Execution Driver: native-0.2
Kernel Version: 3.8.13-35.3.1.el7uek.x86_64
Operating System: Oracle Linux Server 6.6

# docker version
Client version: 1.3.3
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 4e9bbfa/1.3.3
OS/Arch (client): linux/amd64
Server version: 1.3.3
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 4e9bbfa/1.3.3

For more information, see the docker(1) manual page.