Skip to content
Ellie Springsteen edited this page Oct 20, 2016 · 8 revisions

Table of Contents

  1. What is docker?
  2. Why use docker?
  3. Why not use docker?
  4. Creating a Docker Image
  5. Building the Image
  6. Creating the Container
  7. Useful Links

What is docker?

Docker makes running software applications on any system easy. Docker uses containers to wrap software applications so that they can be run with the docker engine on any system.

You can think of the docker engine like a mini-VM, but instead of having all of the overhead of a traditional VM, docker containers run on the host operating system.

Docker containers can have their own filesystem and you can incorporate all of the dependencies for a software application inside of a container so that it is easily portable.

Why use docker?

Docker should be used for software applications that can be encapsulated in a container.

Why not use docker?

Not everything is compatible with docker.

You can't run a linux container on a windows machine.

Docker containers are less isolated than VMs, so a virus in a container can affect the host operating system.

Creating a Docker Image

Dockerfile

Creating an image requires a Dockerfile which is just a text file containing the steps that would be performed in a command line to set up the environment needed to run the application. Below are example commands to include

FROM - sets the base image to use (FROM java:8 uses the image for Java8)

RUN - can be used to run a command or an executable with parameters

CMD - similar to RUN but specifies defaults (can only have 1 in Dockerfile)

EXPOSE - the port the container is listening to at runtime

ADD - copies files from the source (host) to the destination (container)

For more commands and further information see additional Dockerfile commands

Building the image

To build the Docker image run docker build -t <image-name> . from the directory the Dockerfile is located.

The -t option tags the image with a name to be used in later steps.

Additionally, the path to the Dockerfile can be provided as a second parameter instead of the . or a URL can be provided to pull an image from another location like GitHub.

Creating the Container

Once the image has been built, the container can be created via

docker run <image-name>

-d is a flag that can be included before the image name to run the container in the background.

Mapping ports

-p can be used to map a host port to the port the Docker container is listening to.

Examples

-p 4567:4567 means that the service listening at the container's port 4567 can be accessed via localhost:4567

-p 8080:4567 means that the service listening at the container's port 4567 can be accessed via localhost:8080

Useful Links

Documentation

Blog

Releases on github

Forums

Dockerfile Reference

Spark and Docker

Windows Port Mapping Issue

Notes

https://docs.google.com/document/d/1cU_XRdakQ7lMFiPlaKCfAZaXwfxUGMX243xHiXMyiL8/edit