Verbally Flimzy

Ramblings, Observations and Misconceptions

Installing Docker 1.12 in Debian 9 (stretch)

Posted on October 27, 2016

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.

  1. Install the Docker archive keyring:``` sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 58118E89F3A912897C070ADBF76221572C52609D

  2. Configure apt:``` sudo echo “deb https://apt.dockerproject.org/repo debian-stretch main” > /etc/apt/sources.list.d/docker.list

  3. Install the package: 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

  4. 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://"

  5. Reload the systemd configuration:

    sudo systemctl daemon-reload 
    
  6. 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.

Filed under: debian docker Linux