Build a Docker image with repo2docker


Docker images to be used this way must have the jupyterhub package of a matching version with the Helm chart. This documentation is for Helm chart 0.9, and it uses JupyterHub version 1.0.0.

If you can’t find a pre-existing image that suits your needs, you can create your own image. An easy way to do this is with the package repo2docker.

repo2docker lets you quickly convert a Git repository into a Docker image that can be used as a base for your JupyterHub instance. Anything inside the Git repository will exist in a user’s environment when they access your JupyterHub.

repo2docker will attempt to figure out what should be pre-installed, and you can help it out by adding various configuration files to the repository. For example if you include a requirements.txt file in the root level of the repository, repo2docker will pip install the specified packages into the Docker image to be built.

See repo2docker’s documentation for more details.

Below we’ll cover how to use repo2docker to generate a Docker image and how to configure JupyterHub to build off of this image:

  1. Download and start Docker.

    You can do this by downloading and installing Docker. Once you’ve started Docker, it will show up as a tiny background application.

  2. Install repo2docker using pip:

    pip install jupyter-repo2docker

    If that command fails due to insufficient permissions, try it with the command option, user:

    pip install --user jupyter-repo2docker
  3. Create (or find) a Git repository you want to use.

    This repo should have all materials that you want your users to be able to use. You may want to include a pip requirements.txt file to list packages, one per file line, to install such as when using pip install. Specify the versions explicitly so the image is fully reproducible. An example requirements.txt follows:

  4. Get credentials for a docker repository.

    The image you will build for your JupyterHub must be made available by being published to some container registry. You could for example use Docker Hub or Google Container Registry.

    In the next step, you need an image reference for you and others to find your image with.

    An image reference on Docker Hub:


    An image reference on Google Container Registry:<cloud-project-name>/<image-name>:<image-tag>


    • Your image name can be anything memorable.

    • We recommend using the first 7 characters of the SHA in the Git commit as this improves reproducibility. You can get these in various ways, one of which is like this:

      git ls-remote <your-git-repository> | grep HEAD | awk '{ print $1 }' | cut -c -7
  1. Use repo2docker to build a Docker image.

    jupyter-repo2docker \
        --no-run \
        --user-name=jovyan \
        --image=<your-image-reference> \

    This tells repo2docker to fetch master of the Git repository, and uses heuristics to build a Docker image of it.

  2. Push the newly-built Docker image to your repository.

    docker push <your-image-reference>
  3. Edit the JupyterHub configuration to build from this image. Edit config.yaml file to include these lines in it:

          name: <your-image-reference>
          tag: "<tag>"
    If the tag is the first several characters of the SHA and they happen to
    all be numerical, you *must* use quotes around the tag as above in order
    for the YAML to be parsed correctly.
  4. Tell helm to update JupyterHub to use this configuration.

    Use the standard method to apply the changes to the config.

  5. Restart your server if you are already logged in.

    If you already have a running JupyterHub server, you’ll need to restart it from the JupyterHub control panel. Within JupyterLab look at the meny named “Hub”. New users won’t have to do this.


    The contents of your GitHub repository might not show up if you have enabled persistent storage. Disable persistent storage if you want the Git repository contents to show up.

  6. Enjoy your new computing environment!

    You should now have a live computing environment built off of the Docker image we’ve created.