Modifying Docker Images Directly

To modify the environment that your run executes in, you can use the tools described here: Environment Management

However, for an on-premise or VPC deployment, you may wish to maintain your own repository of Docker images. Advantages to doing so include:

  • Creating a common starting-point for defining new images.
  • Prevent wasted time building images on new executors when using the "Raw Dockerfile" section of the environment.
  • If executors in your private deployment do not have outside internet access, this method can be used to install additional libraries that would otherwise be inaccessible.

For an in-depth exposition of Docker image management, you can reference the official documentation.

Getting Started

This guide assumes you’ve already set up a Docker registry somewhere.

First, log onto a machine that you will use to build the new Docker image. This can be an executor in maintenance mode, or any other machine that can pull from/push to your Docker registry (for information on maintenance mode, see the section titled "Instance Actions" in the Cluster Controls article).

Image Naming Convention

When you create your image, you will need to assign it a name as well as a tag. We recommend using different names for different logical use cases or teams, and then using timestamps as tags as they are updated. For example, a collection of images might look something like this:

Instructions for assigning names and tags are included below.

Building an Image: Interactive Modification

You can build an image interactively, by running a container, modifying it, and then committing it back to the repo.

First, run a base image (how to handle authentication, etc?). For example:

docker run -it -u root /bin/bash

The prompt will show an ID, e.g. if you see root@78e82f680994$, then the ID is 78e82f680994. This is the container ID. Take note of this, as you will need it later.

Next, install libraries and make any other modifications the running container as needed. When finished, exit the container:


Next, commit the container (using the ID you noted earlier), assigning it a name and a tag:

docker commit <container ID>

This will return an image ID.

Building an Image: Using a Dockerfile

Instead of modifying a running container interactively, you can alternatively install from a Dockerfile. The syntax is the same as used in the “Raw Dockerfile” section of environment management. For an in-depth look at best-practices for writing Docker files, you may reference the official documentation.

Once you’ve created the definition, save it to a file named “Dockerfile”. Place this file in a folder on the machine that has access to the repo. Navigate into the folder, and then use a docker build command like the one below to create the image. For example:

mkdir myimage
cp /path/to/Dockerfile myimage/Dockerfile
cd myimage
docker build -t .

The -t parameter specifies an image tag so you can identify and use this image later. Be sure to run the docker build command from within the directory that contains the Dockerfile. When the build has finished, it will return an image ID.

Building an Image: Pushing to the Repo

Finally, push your image to the repo, in order to make it available to your runs:

docker push
Was this article helpful?
0 out of 0 found this helpful