Create a derivative container

This page describes how to create a derivative container based on oneof the standard available Deep Learning Containers images.

To complete the steps in this guide, you can use eitherCloud Shell or anyenvironment where theGoogle Cloud CLI is installed.

Before you begin

Before you begin, make sure you have completed the following steps.

  1. Complete the set up steps in the Before you begin section ofGettingstarted with a local deep learningcontainer.

  2. Make sure that billing is enabled for your Google Cloud project.

    Learn how to enablebilling

  3. Enable the Artifact Registry API.

    Enable theAPI

The Process

To create a derivative container, you'll use a process similar to this:

  1. Create the initial Dockerfile and run modification commands.

    To start, you create a Deep Learning Containers container usingone of theavailable image types.Then use conda, pip, orJupyter commands to modify the containerimage for your needs.

  2. Build and push the container image.

    Build the container image, and then push it to somewhere that isaccessible to your Compute Engine service account.

Create the initial Dockerfile and run modification commands

Use the following commands to select a Deep Learning Containers image typeand make a small change to the container image. This example shows how tostart with a TensorFlow image and updates the imagewith the latest version of TensorFlow.Write the following commands to the Dockerfile:

FROM us-docker.pkg.dev/deeplearning-platform-release/gcr.io/tf-gpu:latest# Uninstall the container's TensorFlow version and install the latest versionRUN pip install --upgrade pip && \    pip uninstall -y tensorflow && \    pip install tensorflow

Build and push the container image

Use the following commands to build and push the container image toArtifact Registry, where it can be accessed by yourGoogle Compute Engine service account.

Create and authenticate the repository:

exportPROJECT=$(gcloudconfiglistproject--format"value(core.project)")gcloudartifactsrepositoriescreateREPOSITORY_NAME\--repository-format=docker\--location=LOCATIONgcloudauthconfigure-dockerLOCATION-docker.pkg.dev

Replace the following:

  • LOCATION: The regional or multi-regionallocation ofthe repository, for exampleus. To view alist of supported locations, run the commandgcloud artifacts locations list.
  • REPOSITORY_NAME: The name of the repositorythat you want to create, for examplemy-tf-repo.

Then, build and push the image:

exportIMAGE_NAME="LOCATION-docker.pkg.dev/${PROJECT}/REPOSITORY_NAME/tf-custom:v1"dockerbuild.-t$IMAGE_NAMEdockerpush$IMAGE_NAME

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.