Docker allows you to package an application with all of its dependencies into a standardized unit for software development.

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.

Docker Images vs Docker Containers

Docker Images are the basis from which Docker containers are created. When you startup a Docker image, a docker container is created. I liken it to classes and objects. The image (class) represents all of the capabilities of the container (object) once it is instantiated but an image cannot do anything. Once a container is created, it can be started and stopped freely and it saves its state. You can create multiple instances of a particular image as long as you give them different names.

Working with Docker Images

Installing Docker using homebrew

$ brew install docker

If you are not a user of HomeBrew for package management, I highly recommend it. You can get more information on it and how to install it at : Homebrew

Open bash prompt in a container

This command creates a container from the specified image ($image_id), opens a bash shell into it and returns the container id (CONTAINERID)

List all images in your local repository

$ docker images

Remove all untaged images (registry cleanup)

$ docker rmi $(docker images | grep "^<none>" | awk "{print $3}")

Working with containers

Open bash shell in a container

To launch a container, simply use the command docker run + the image name you would like to run + the command to run within the container. If the image doesn’t exist on your local machine, docker will attempt to fetch it from the public image registry.