Customize Cloud Shell container images

This page describes how to create and use a custom Docker image as a Cloud Shell environment.

To create a custom Cloud Shell experience, create a Docker image that functions as a custom Cloud Shell environment with your specified additional packages and custom configurations. Your Docker image must be based on the base Cloud Shell image and hosted in Container Registry.

Create a custom Docker image

To follow step-by-step guidance for this task directly in the Cloud Shell Editor, click Guide me:

Guide me

Create your own custom Docker image by following these instructions:

  1. In a Cloud Shell terminal tab, run the following command to create a boilerplate custom image in a repository hosted by Cloud Source Repositories:

    cloudshell env create-custom-image NEW_REPO_NAME

    Alternatively, if you'd prefer to manually deploy to Container Registry or use your own automation flow, you can create a new, empty Dockerfile and skip to step 3.

  2. Open your new Dockerfile by following the instructions printed to your command line:

    cd $HOME/NEW_REPO_NAME && cloudshell edit Dockerfile
  3. Add any additional packages you want made available in your Cloud Shell experience below the first line. For example:

    RUN apt-get -y install lsof

    The first line in your Dockerfile, FROM, references the base Cloud Shell image and shouldn't be removed.

  4. Build your image locally by running:

    cloudshell env build-local
  5. Test your image locally and verify that your installed packages are present by running:

    cloudshell env run

    To exit testing, run:

  6. Commit your code changes locally:

    git commit -a -m "Initial custom environment check-in."
  7. Push your code changes to Cloud Source Repositories:

    git push origin master
  8. Finally, push your custom image to Container Registry:

    cloudshell env push

To use your custom image with Open in Cloud Shell links, you need to make it public first. For steps to make a custom image public, follow the Container Registry access control guide.

After you've set up the right access settings, you can update your Open in Cloud Shell link to specify the cloudshell_git_repo and cloudshell_image parameters. For example, to add an Open in Cloud Shell button, edit the URLs in following example and then add a link similar to the following to your Markdown file:

[![Open in Cloud Shell](](

Replace the following values:

  • REPO_URL: URL to the location of your repository
  • DOCKER_IMAGE_URL: URL to the Docker image

For more information about these and other parameters, see Open in Cloud Shell.

Keeping custom container image up-to-date

Your custom container must be based on the latest public Cloud Shell image to work on Cloud Shell. We recommend that you perform weekly rebuilds to keep the custom image up-to-date.