Once you get a bit of a rhythm with docker, it becomes pretty fun. Here are notes I took while reading some Docker books. Two good ones that I'd recommend are:

Useful commands


Old and busted

New hotness

Difference between Stopped Container and Image: stopped container retains its changes, settings, metadata, filesystem, runtime configuration, etc. Images don't have runtime information.


FROM centos:7
MAINTAINER Beech Team <>
RUN yum update && yum install -y emacs

Note: each command creates a layer, so try to squeeze stuff into a single command.

Then build it like this:

docker build -t test/myemacs .

And run it like this:

docker run test/emacs emacs .bashrc

If you add this line to the Dockerfile:

ENTRYPOINT ["/usr/bin/emacs"]

then you can directly run the container and pass the args without mentioning the command, i.e.

docker run test/emacs .bashrc

COPY in a Dockerfile instructs docker to copy a file from the host to the container. e.g.


VOLUME is used to just use the host's filesystem for persistent data. e.g.

VOLUME /home/arunsrin/data:/root/data

To do it at run time, do this:

docker run -it -v `pwd`:/root arunsrin/testpy

Instead of VOLUME, if you use ADD or COPY, it'll be baked into the image and available to anyone who downloads it. e.g. requirements.txt. Use ADD or COPY for making it part of the image, and VOLUME for sharing data between host and container. Unlike COPY, ADD also accepts URLs as a source, and unpacks it if its an archive. e.g.

ADD . /python-oauth

When running a command like docker build -t asda/asd . , the '.' is the build context. It's contents are tar'd and sent to the docker daemon so that ADD and COPY commands work seamlessly. Don't run this on a large folder like ~ !!

docker-compose: stop all containers when one dies

From here:

docker-compose up --abort-on-container-exit

This will stop all containers launched via docker-compose when one of the containers stops.

Run redis on windows

My teams' integration tests need this and I'm the only windows guy!

docker run -d -p 6379:6379 redis:6