Ramblings, Observations and Misconceptions

Menu

Installing Docker 1.12 in Debian 9 (stretch)

Debian ships with an old version of Docker, and the official installation instructions for Docker on Debian are a bit dubious (run an entirely untrusted shell script as root! yay!), not to mention error-prone, and result in a completely non-functional Docker installation on Debian, thanks to aufs being deprecated.

So these instructions should make it possible to install Docker 1.12 on Debian Stretch. At least for now. Stretch is a moving target, so these instructions may become quickly outdated.

If you had an old, Debian-official version of docker installed, you should remove it first:

sudo aptitude purge docker

Then install the new one:

sudo aptitude install docker-engine

Configure the service:

This is the most complicated part, which required some investigation. You’ll need to edit the systemd service file, to tell it to use an environment file. So open /lib/systemd/system/docker.service. You will then make two changes, both in the [Service] section.

[Service]
+EnvironmentFile=/etc/default/docker
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
-ExecStart=/usr/bin/dockerd -H fd://
+ExecStart=/usr/bin/dockerd $DOCKER_OPTS
ExecReload=/bin/kill -s HUP $MAINPID

First, add the line EnvironmentFile=/etc/default/docker at the top of the [Service] section.

Second, on the ExecStart= line, replace -H fd:// with $DOCKER_OPTS.

Together, these changes tell the docker service to read the /etc/default/docker file for environment variables.

Then, edit (or create) the file /etc/default/docker, and make sure it contains the following, uncommented line:

DOCKER_OPTS="--storage-driver=overlay -H fd://"

This tells dockerd to use the overlay filesystem, instead of the obsolete default of aufs.

Reload the systemd configuration:

sudo systemctl daemon-reload

Start docker:

sudo /etc/init.d/docker start

That should do it! Please let me know if you experience any problems, or I need to update anything here.