Return home

Docker Basics


This is a quick guide for getting started with developing software projects using Docker. It assumes you’ve already followed an installation guide on the Docker website.


Create a Dockerfile

Docker uses a custom syntax for building an image. Here is an example Dockerfile that uses Ubuntu 14.04 LTS and installs some packages:

# use ubuntu 14.04 LTS
FROM ubuntu:14.04

# update the apt-get package repositories
RUN apt-get update -y

# install some packages
RUN apt-get install -y erlang

The Dockerfile is usually found in the directory of the project you’re wanting to create a docker container for.

Create a Docker image

The command docker build creates the image. To distinguish your image from other images, give it a tag. A tag is in the format of repo:tag. The following will build a Docker image from the Dockerfile in the current directory (without the tag part):

docker build -t "ubuntu/erlang" .

Create a docker container

Now that the image is created, the container can be created from the image using docker create:

docker create -i -t --name erlang -v $PWD:/app "ubuntu/erlang" /bin/bash

This creates an interactive docker container, named erlang that mounts the local host filesystem to a directory on the container called /app. Now local edits to the project will be available to the new container.

Start the container and test

Use docker start to boot up the container and create an interactive shell:

docker start -a -i erlang 

At this point you can list files in your mounted volume and run commands from the container:

nuex@straylight:~/_dev/resmatch$ docker start -a -i erlang
root@a534eb68a503:/# ls /app
Dockerfile  LICENSE  rebar.config  src  test

Useful Docker commands

Here are some useful commands for cleaning up containers while working with docker.

To list all started containers, use docker ps:

docker ps -a

If you want to stop all of the containers:

docker kill $(docker ps -a -q)

If you want to delete all containers after you’ve stopped them:

docker rm $(docker ps -a -q)


At this point you should have a running container that can be used for development and a basic understanding of how to add packages to the container, run commands and mount projects.