Docker quick start

Docker is a useful tool for creating small virtual machines called containers. Containers are instances of docker images, which are defined in a simple language. This language is usually written in a file called Dockerfile and it’s common practice to version control these files. When you run a container on your computer you get access to an entirely separate Linux environment. Better yet, you can run the same container on your laptop as you run code in production, giving you the opportunity to develop and test in a realistic environment. This takes one major source of uncertainty out of the process of running your code on another machine.

Using Docker on a Mac is easy (although untested, the process should be very similar on Windows). Here are a few steps to get started.

Build and launch the container

  1. Install the latest stable client here.
  2. Create a folder called hello-docker and. Create a file called Dockerfile in it with the following:
FROM jupyter/minimal-notebook

CMD --NotebookApp.token=''
  1. Navigate to the hello-docker folder in your terminal and run the following:
docker build -t insecure-notebook .
  1. Next, start your container:
docker run -d -p 8888:8888 insecure-notebook
  1. Navigate to localhost:8888 in your browser. Welcome to your container-hosted Jupyter notebook!

Take the container down

  1. Run docker ps to see which containers are running. You should see something like this:
>>> docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
5ccfea1e3720        insecure-notebook   "tini -- /bin/sh -..."   4 minutes ago       Up 4 minutes>8888/tcp   vigilant_austin
  1. Copy the container ID of your notebook.
  2. Kill and delete the container:
docker rm -f <container ID>

For me, this looks like:

docker rm -f 5ccfea1e3720


comments powered by Disqus