Kevin's Worklog

Documenting the Daily Stream

Entering a Docker Container

I’ve been learning more about Docker and I’ve stumbled into the need to enter into a running Docker container so that I can check log files to see why a service isn’t running. I learned from a StackOverflow post that there is a new Docker command that lets you easily do this:

docker exec -it [container-id] bash

However, it’s only available in Docker version 1.3 or greater. The version of Ubuntu that I’m running has Docker 1.2. So, I want to add the Docker PPA so I can get more frequent updates from the Docker developers. To do that, I run the following commands:

wget -qO- | sudo apt-key add -
sudo sh -c "echo deb docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker

This also uninstalls the ‘’ version of the package that’s found in the regular Ubuntu package repository. After installing the newer Docker version, I can use the nifty docker exec function.

Update: The above currently installs Docker 1.4.1, but there is an issue with this version of Docker that causes my builds to fail. To resolve this, a particular version of Docker (above 1.3 and below 1.4.x) can be installed with the following command:

sudo apt-get install lxc-docker-1.3.3

**Update (Slight Return): And, a handy modification to the docker command is:

docker exec -it $(docker ps -l -q) bash

This will let you into the Docker container that you just started.