🚢 Learn how to use docker.io containers to consistently deploy your apps on any infrastructure.
Nginx HTML
Switch branches/tags
Nothing to show
Clone or download


Docker: Believe the Hype!

Docker Logo

Learn how to use docker.io containers to consistently deploy your apps on any infrastructure.

What? (Quick Introduction)



If your laptop/pc is not running Linux you will need to Download the Docker Toolkit**.pkg** (Mac) or docker-toolkit.exe (Windows) and install it on your Mac/PC.


Sadly, Docker Toolkit is the "official" way of running docker on Mac so we have to swallow the 453Mb pill
and get on with it! (click install!)


### Next Steps

You might as well get a Docker Hub account now (reserve your username on dockerhub): https://hub.docker.com/ Docker Hub lets you store your docker files (public & private) so you can share these with people and deploy them anywhere.

Open the Docker Quickstart Terminal App

Open the Docker Quickstart Terminal App


This will open your terminal and run the boot script (wait a couple of minutes for it to finish...) quickstart

Run the suggested command:

$ docker run hello-world


Next try to run an ubuntu container (only do this on a fast internet connection as its going to download 65mb ubuntu image)

docker run -it ubuntu bash

download ubuntu

This will boot the Ubuntu image and log you into the container's bash. You can confirm that you are in a Linux bash by running the following command: cat /etc/os-release


List the containers currently running:

docker-machine ls

Which shows:

NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default            virtualbox   Running   tcp://

And for even more detail, run docker info

Containers: 2
Images: 6
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 10
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.0.9-boot2docker
Operating System: Boot2Docker 1.8.1 (TCL 6.3); master : 7f12e95 - Thu Aug 13 03:24:56 UTC 2015
CPUs: 1
Total Memory: 1.956 GiB
Name: default
Debug mode (server): true
File Descriptors: 9
Goroutines: 20
System Time: 2015-08-16T22:27:21.593654583Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker

Run the Dockerfile in this repo

First build the image:

docker build -t learn-docker .

Then run the image as a container:

docker run -it -p 8888:8888 learn-docker bash



docker exec -it learn-docker bash

List (Locally Available) Images

View the current (locally) available docker images:

$ docker images

You should see:

REPOSITORY          TAG                 IMAGE ID            CREATED                  VIRTUAL SIZE
learn-docker        latest              0c495aa0e6dc        Less than a second ago   261.6 MB
ubuntu              14.04               8251da35e7a7        8 days ago               188.4 MB
ubuntu              latest              8251da35e7a7        8 days ago               188.4 MB
hello-world         latest              af340544ed62        9 days ago               960 B

docker ps

To list all the running docker containers, use:

docker ps -a


More info on a specific container

To get more detail on a container type: docker inspect {imageid}

e.g: in our case the container we are interested in has the id: a205fc3a096f so we run:

docker inspect a205fc3a096f

The complete output of this command is in: /sample-docker-inspect.txt

Just the IP address

If all we want is the container's IP address we run:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' a205fc3a096f
where the last argument is the container (image) id.
Courtesy of: http://stackoverflow.com/a/20686101/1148249

Kill a Container by ID

docker stop a205fc3a096f



For some reason I'm unable to access the nginx server running inside the docker container ... looked at:

is nginx working?

Test that your nginx configuration is valid (doen't have errors)

sudo nginx -t

expect the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Useful Links

Cheat Sheet