Docker

Existing Docker images are available at https://registry.hub.docker.com/. If you use docker you should create an account so that you can upload and store your own images.

Docker Basics

A note about developing with Docker on Mac OS X

Docker runs on Linux. You can run it on Mac using boot2docker, but it fires up VM to run the linux image in VirtualBox. Managing the size of the VirtualBox VM is a pain and Docker often runs up against the size limitation. I've found it's better to run a Linux VM in VMWare Fusion, and running Docker in that image.

Docker commands

Start a Docker Container

sudo docker start <container_id> # Start
sudo docker stop <container_id>  # Stop

To start docker interactively:

sudo docker run -i -t ubuntu /bin/bash

# ubuntu is the name of the the docker container. 
# You could also use the container id (hex) instead

To start docker interactively with sudo privelages

sudo docker --privelaged -i -t ubuntu /bin/bash

# now sudo and mounts work
mount -t tmpfs stuff /mnt

Show Docker processes

sudo docker ps    # show running docker containers
sudo docker ps -a #  ... also shows process history

Run Docker container continuously

sudo docker start <container_id>
sudo docker ps                   # find id of process
sudo docker inspect --format "{{ .State.Pid }}" <container_id> # Find local pid (process id)

# This command will enter a running docker container w/ a terminal session
sudo nsenter --target <pid> --mount --uts --ipc --net --pid

NOTE: https://github.com/jpetazzo/nsenter for installing nsenter on Ubuntu. It also installs docker-enter which is handy for entering running containers:

sudo docker-enter <container_id>

Working with Docker Images

sudo docker images               # list image on my system and their ids
sudo docker pull <image_name>    # pulls and preloads image
sudo docker search <search_term> # Search images with names like search_term

# A refined search example
sudo docker search apache | grep ubuntu

You can use apt-get inside a container to install software in it. Then, to commit it locally:

sudo docker commit -a="Brian Schlining" <container_id> <new_local_image_name>

Videos