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.
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.
Add the official GPG key for Docker.
Verify the fingerprint is correct (9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88)
Set up the stable Docker repository and update the apt package index.
Install the latest version of Docker CE (note this will install other packages as required)
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.
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.
Before beginning, stop docker and make adjustments if you are changing the default directory for docker files
- Create/modify files
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:
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.
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.
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)
Verify the versions of docker-compose and docker-ce that have been installed using either --version or -v
Add users specifically to the docker group.
If necessary, modify the /etc/sudoers file. You can add groups, etc. In addition, we had to add change the authenticate env variable
- See this link for some generic Linux commands, and here for some useful docker commands.