February 20, 2016 · docker travis-ci

Managing Docker & Docker Compose versions on Travis

When Travis launched Docker Support, I assumed it would let you manage the versions of Docker and Docker Compose - that is far from correct.

What I wanted to do:

Should be a simple config change right? Think again.

The following is a .travis.yml recipe that I've come up with for managing which versions of docker and docker-compose get installed into your environment.

sudo: required

language: go

services:  
    - docker

env:  
    global:
        - DOCKER_VERSION=1.10.1-0~trusty
        - DOCKER_COMPOSE_VERSION=1.6.0

before_install:  
    # list docker-engine versions
    - apt-cache madison docker-engine

    # upgrade docker-engine to specific version
    - sudo apt-get -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION}

    # reinstall docker-compose at specific version
    - sudo rm -f /usr/local/bin/docker-compose
    - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
    - chmod +x docker-compose
    - sudo mv docker-compose /usr/local/bin

script:  
    - docker version
    - docker-compose version

Pay attention to the output of the apt-cache madison docker-engine, that displays the available versions of docker-engine in apt.dockerproject.org/repo - you'll want to make sure that DOCKER_VERSION is set to the desired version in your .travis.yml, eg 1.10.1-0~trusty:

$ apt-cache madison docker-engine
docker-engine | 1.10.1-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.10.0-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.9.1-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.9.0-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.8.3-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.8.2-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.8.1-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.8.0-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.7.1-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.7.0-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.6.2-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.6.1-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.6.0-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  
docker-engine | 1.5.0-0~trusty | https://apt.dockerproject.org/repo/ ubuntu-trusty/main amd64 Packages  

Remember, Travis CI is a black-box, so output is your friend - output the versions for docker and docker-compose either in before_install after you do the install or in script before running your tests:

$ docker version
Client:  
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:27:08 2016
 OS/Arch:      linux/amd64
Server:  
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:27:08 2016
 OS/Arch:      linux/amd64

$ docker-compose version
docker-compose version 1.6.0, build d99cad6  
docker-py version: 1.7.0  
CPython version: 2.7.9  
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013  

Cheers.