Page tree
Skip to end of metadata
Go to start of metadata

This document describes how to install docker-ce on Ubuntu 16,04,3 LTS, which is the most current supported version of Ubuntu. This follows the official Docker installation guide for Ubuntu.

Step-by-step guide

  1. Install required packages. Some of these may already be at the latest version; if so, they will be automatically be skipped. Note that for Ubuntu 16.04 and higher, the Linux kernel includes support for OverlayFS, and Docker CE will use the overlay2 storage driver by default.

    sudo apt-get update
    sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
  2. Add the official GPG key for Docker.

    curl -fsSL | sudo apt-key add -
  3. Verify the fingerprint is correct (9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88)

    sudo apt-key fingerprint 0EBFCD88
    pub   4096R/0EBFCD88 2017-02-22
          Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid                  Docker Release (CE deb) <>
    sub   4096R/F273FCD8 2017-02-22
  4. Set up the stable Docker repository and update the apt package index.

    sudo add-apt-repository \
       "deb [arch=amd64] \
       $(lsb_release -cs) \
    sudo apt-get update
  5. Install the latest version of Docker CE (note this will install other packages as required)

    sudo apt-get install docker-ce

    Verify that Docker CE is installed correctly by running a small container.  This will download a test image and run a container.  It will print an informational message if it runs successfully.

    sudo docker run hello-world
    ##message from a successful installation:
    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.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    Share images, automate workflows, and more with a free Docker ID:
    For more examples and ideas, visit:
  6. Some default options need to be changed.  There are two ways to do this.  One is to adjust /etc/default/docker file and the /lib/systemd/system/docker.service file . The other way involves creating a /etc/docker/daemon.json file.  Docker recommends using a daemon.json file, so that is listed here. There are a few reasons you may want to adjust this file, including using a different directory for the default docker files. Another reason is ensure the docker daemon uses both the tcp socket and the unix socket. See here for information on systemd and docker.

    If you plan to adjust the default directory for docker files, do so before doing any work with docker

    Note these directions are for Ubuntu 16.04.3 LTS and above.  Older versions of Ubuntu do not use systemd.  If using an older system, changing the /etc/default/docker file should suffice.  However, some options may be deprecated by Docker in future versions.  That method is not listed in this documentation.

    1. Before beginning, stop docker and make adjustments if you are changing the default directory for docker files

      ##Stop Docker
      sudo service docker stop
      ##Create a new directory if you are changing the default directory for docker files 
      sudo mkdir -p /data/docker
    2. Create/modify files
      1. Create /etc/docker/daemon.json file (note some of the names of the parameters have changed).  More information is available here and here

          "hosts" : ["unix:///var/run/docker.sock", "tcp://"],
          "graph" : "/data/docker"
      2. If changes are made to the /lib/systemd/systems/docker.service file, they could be overwritten during an update. Docker recommends using an override file.  AFTER creating the /etc/docker/daemon.json file:

        systemctl edit docker <-- this creates (if it doesn't exist) or modifies /etc/systemd/system/docker.service.d/override.conf 
        ##Add this to the file for the docker daemon to use different ExecStart parameters (more things can be added here)
    3. Restart docker

      ##Reload the systemctl daemon 
      sudo systemctl daemon-reload 
      ##restart docker
      sudo service docker start
      systemctl restart docker
      ##Check daemon status
      systemctl status docker
    4. If the default docker directory file location was changed, verify new files are being written to that directory, and then delete the old docker directory if desired.

      ##In the example, we changed the default docker directory to /data/docker.  These are the directories that should exist once the docker daemon is restarted:
      aufs  containers  image  network  plugins  swarm  tmp  trust  volumes
      ##do not do this on a system that is not being initially setup or you could lose information and potentially break the system
      sudo rm -r /var/lib/docker

    If you already have containers defined and you make a change to the default docker file locations, they will no longer be working.  Restart them with docker-compse up -d and the volumes, networks, and containers will be redefined.  If you have already loaded data, you will need to re-import.

  7. Install docker-compose.  Docker-compose is not an application like docker and is not obtained/updated using the normal package manager (and is not updated with the apt package).  It is a file downloaded from github.  Specify the version when downloading.  The list of docker-compose releases is here.  To install a new version, use the same command and specify the new version to be installed.

    If you get a "permission denied" error message while running the curl command, it means the /usr/local/bin directory is not writable.  Become the sudo user (sudo -i or sudo -s) and rerun the curl command (and the chmod command)

    curl -L`uname -s`-`uname -m` > /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose
  8. Verify the versions of docker-compose and docker-ce that have been installed using either --version or -v

    docker -v (or docker --version)
    Docker version 17.06.2-ce, build cec0b72
    docker-compose -v (or docker-compose --version)
    docker-compose version 1.16.1, build 6d1ac21
  9. Add users specifically to the docker group.

    sudo usermod -a -G docker username
  10. If necessary, modify the /etc/sudoers file. You can add groups, etc.  In addition, we had to add change the authenticate env variable

    ##some changes
    Defaults        env_reset,!authenticate
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
  11. See this link for some generic Linux commands, and here for some useful docker commands.