GoLand 2023.2 Help

Docker images

Docker images are executable packages for running containers. Docker uses registries to distribute images. By default, GoLand uses Docker Hub, which is a public registry with all the most common images, such as various Linux flavors, database management systems, web servers, and runtime environments. There are other public and private Docker registries, and you can also deploy your own registry server. For more information, see Configure a Docker registry.

Enable the Docker plugin

This functionality relies on the Docker plugin, which is bundled and enabled in GoLand by default. If the relevant features aren't available, make sure that you didn't disable the plugin.

  1. Press Control+Alt+S to open the IDE settings and then select Plugins.

  2. Open the Installed tab, find the Docker plugin, and select the checkbox next to the plugin name.

To manage Docker images in GoLand, open the Services tool window ( View | Tool Windows | Services or Alt+8), expand the configured Docker connection node Docker node, and then expand the Images node. For more information, see Images.

Depending on your development needs, you can use Docker for the following:

  • Pull pre-built images from a Docker registry

    For example, you can pull an image that runs a PostgreSQL server container to test how your application will interact with your production environment.

  • Build images locally from a Dockerfile

    For example, you can build an image that runs a container with a specific version of the Java Runtime Environment (JRE) that your application requires.

  • Push your images to a Docker registry

    For example, if you want to demonstrate to someone how your application runs in some specific version of the JRE instead of setting up the proper environment, they can run a container from your image.

Configure a Docker registry

  1. In the Services tool window, click the Add Service button and select Docker Registry.

    Services tool window - Add Docker Registry
  2. In the New Docker Registry dialog, specify how to connect to the registry. When you specify the credentials, GoLand will automatically check the connection to the registry. The Connection successful message should appear at the bottom of the dialog.

    Add new Docker Registry

You can see the configured Docker registries in the Services tool window.

Docker registries in Services

Alternatively, you can manage the list of configured Docker registries in Docker Registry settings.

Pull a public image from Docker Hub

  1. In the Services tool window ( View | Tool Windows | Services or Alt+8), select the Images node.

  2. Under Images Console, type the name of the image to pull.

    Use completion to select from the available suggestions of official images. Press Control+Space again to see relevant images from all users.

  3. Press Control+Enter to run docker pull.

Specify the image as in the Docker CLI, for example: golang:latest.

The Pull Image dialog

Pull an image from a Docker registry

If you want to work with private images on Docker Hub or in some other Docker registry, configure a Docker registry connection.

  • In the Services tool window ( View | Tool Windows | Services or Alt+8), expand the node with the necessary Docker registry, right-click the image that you need, and select Pull Image….

    Pull image from a configured registry

Build an image from a Dockerfile

When you're editing a Dockerfile, GoLand provides completion for images from the configured registries.

  1. Open the Dockerfile from which you want to build the image.

  2. Click Run on Docker in the gutter and select to build the image.

    The Run on Docker popup

GoLand creates a Dockerfile run configuration that runs the docker build command.

Push an image to a Docker registry

You can push an image to a configured Docker registry.

  1. In the Services tool window, select the image that you want to upload and click The Push Image button on the toolbar or in the Dashboard or select Push Image… from the context menu.

  2. Select the Docker registry and specify the repository and tag (name and version of the image, for example, my-app:v2).

  3. Click OK to run the docker push command.

    The Push Image context menu item

Copy image to another Docker daemon

If you have several Docker daemon connections, you can copy an image from one Docker daemon to another.

  1. In the Services tool window, select the image that you want to copy and click The Copy Docker Image button or select Copy Docker Image from the context menu.

  2. In the Copy Docker Image dialog, select the Docker daemon to which you want to copy the image and click Copy.

This first runs the docker save command to save the image from the current Docker daemon as a file, and then the docker load command to load the image from the file on the target Docker daemon.

Manage Docker images in the Services tool window

GoLand lists all images that you pull or build locally in the Services tool window under the Images node of the corresponding Docker daemon connection. For more information, see Images.

Select an image to view its name, ID, size, tags, date of last changes, and containers that are using this image. You can create a new container from the selected image, push the image to a configured Docker registry, or view the layers used by the image. Click the More button to see more actions: copy the image ID to the clipboard, run the docker image inspect command, or show labels applied to the image.

Docker image properties

Images with no tags <none>:<none> can be one of the following:

  • Intermediate images that serve as layers for other images and don't take up any space.

  • Dangling images that remain when you rebuild an image based on a newer version of another image. You should regularly prune dangling images to preserve disk space.

To hide untagged images from the list, click The Filter menu on the Docker toolbar and remove the checkmark from Untagged Images.

To delete one or several images, select them in the list and click The Delete Image button.

Explore Docker images

  1. In the Services tool window, under Images, select the image you're interested in.

  2. In the Dashboard tab, click Show Layers.

  3. The Layers tab shows all layers that make up this image with details about each layer. Click Analyze image for more information to gather detailed information including changes to the image's file system.

You can double-click or right-click any file in an image's layer to open a copy of it in the editor if GoLand supports this file type, or download a copy of the file to your local file system if GoLand doesn't support this file type.

Open a file from a Docker layer
Last modified: 22 August 2023