Upgrading Docker

23Jun15

Dockercon #2 is underway, version 1.7.0 of Docker was released at the end of last week, and lots of other new toys are being launched. Time for some upgrades.

I got used to Docker always restarting containers when the daemon restarted, which included upgrades, but that behaviour went away around version 1.3.0 with the introduction of the new –restart policies

Here’s a little script to automate upgrading and restarting the containers that were running:

upgrade-docker.sh

#!/bin/bash
datenow=$(date +%s)
sudo docker ps > /tmp/docker."$datenow"
sudo apt-get update && sudo apt-get install -y lxc-docker
sudo docker start $(tail -n +2 /tmp/docker."$datenow" | cut -c1-12)

I also ran into some problems with Ubuntu VMs where I’d installed from the old docker.io repos that have now moved to docker.com.

I needed to change /etc/apt/sources.list.d/docker.list from:

deb http://get.docker.io/ubuntu docker main

to:

deb https://get.docker.com/ubuntu docker main

The switch to HTTPS also meant I needed to:

apt-get install apt-transport-https