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. This requires a slight modification of the /lib/systemd/system/docker.service file if the hosts option is being modified. Both ways are 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.
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.
Before beginning, stop docker and make adjustments if you are changing the default directory for docker files
Example DOCKER_OPTS section of /etc/default/docker file. More information on some of the options that can be used is available here.
Changes in the /lib/systemd/system/docker.service file Service section so it will use the /etc/default/docker file.
- Method 2 (this is the recommended method according to the latest Docker documentation)
Make changes to the /lib/systemd/system/docker.service file to remove the -H fd:// startup option in the ExecStart only if the "hosts" option is used in the 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
Note - you may want to add a user/users specifically to the docker group. After installing the ssdt utilities, I ran into an error message when I ssh'd into the server (it didn't cause any issues). Adding my username to the docker group resolved the message.
- See this link for some generic Linux commands.