Snippets for tweaking and troubleshooting docker

An aide-mémoire for fixing common docker problems

I use docker for my local data science development environment, as well as when deploying to AWS / Digital Ocean using dokku. I have spoken about this before (lightning talks 1 and 2 at PyData London meetup, talk at the Data Science Lab meetup) but I felt I needed a place to collect all the troubleshooting tricks and performance tweaks I use over time.

Client-server version mis-match

When you see this:

Error response from daemon: client and server don’t have same version (client : 1.13, server: 1.12)

Do this:

$ docker stop
$ docker download
$ docker start


Out of RAM

If high memory processes are crashing or “boot2docker ssh top” tells you that your memory usage is causing too much paging, you may want to increase the boot2docker VM’s RAM:

$ boot2docker stop
$ VBoxManage modifyvm boot2docker-vm --memory 10240
$ boot2docker start
$ boot2docker info
{ ... 'Memory': 10240 ... }

This will change the RAM without deleting any persistent data.

I give boot2docker 10Gb on a 16Gb machine and it works pretty well. You can always do “boot2docker stop” if you need more on the host for a bit.


Changes in my docker hub image aren’t in sync

Run (for example):

$ docker pull calvingiles/data-science-environment

Too many docker containers and images hanging around

Use `—rm` whenever you use `-it` to have containers automatically clean themselves up.

Clean up lots of containers at once (ubuntu based in this case) with:

$ docker ps -a | grep ubuntu | awk ‘{print $1}’ | xargs docker stop
$ docker ps -a | grep ubuntu | awk ‘{print $1}’ | xargs docker rm

Clean up lots of images at once (in this case where they have no name) with:

$ docker images | grep ‘<none>’ | awk ‘{print $3}’ | xargs docker rmi

You can build up these from the left by adding each piped command one at a time.

No space left on volume

If you have cleaned up old containers and you are still get `no space left on volume` when building, pulling or running, you can increase the size of boot2dockers volume. The official instructions are good, just follow them step by step:

boot2docker won’t start

If you get this message:

error in run: Failed to start machine “boot2docker-vm”: exit status 1

you can often fix the issue by starting via VirtualBox.

First, open the VirtualBox app (/Applications/VirtualBox) and start the `boot2docker-vm` with the `start` button or run the following to start boot2docker with a head:

$ VirtualBox —startvm boot2docker-vm

Note: this will open a window with the boot2docker display output and will keep the terminal process so you will need to open another terminal for the next command.

Second, stop the boot2docker process using the boot2docker cmd:

$ boot2docker stop

This will close the boot2docker window and the previous terminal process will exit.

Third, start the boot2docker process using the boot2docker cmd:

$ boot2docker start

For me, this (combined occasionally with an OS X reboot) has always fixed the issue.

I forgot to use —rm when I did docker exec

You can run this to see all the containers started with exec:

$ docker ps -a —no-trunc | grep ‘ “/exec ‘ | sed ‘s/ */\ /g’

StreamOutputError: image not found

If you see something like this when running `docker pull` or `docker run`:

compose.progress_stream.StreamOutputError: Error: image <repo/image:tag> not found

it could be because you have a typo in the repo name, but it could also be because the repo is private and you haven’t run `docker login` yet. Just type

$ docker login

and follow the instructions.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.