CLion 2024.1 Help

Docker plugin integration

Docker is a tool for deploying and running executables in isolated and reproducible environments. This may be useful, for example, to test code in an environment identical to production.

CLion integrates the Docker functionality and provides assistance for creating Docker images, running Docker containers, managing Docker Compose applications, using public and private Docker registries, and much more directly from the IDE.

Enable the Docker plugin

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

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

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

Install and run Docker

Connect to the Docker daemon

  1. Press Ctrl+Alt+S to open settings and then select Build, Execution, Deployment | Docker.

  2. Click The Add button to add a Docker configuration and specify how to connect to the Docker daemon.

    The connection settings depend on your Docker version and operating system. For more information, refer to Docker connection settings.

    The Connection successful message should appear at the bottom of the dialog.

    The Docker connection settings

    For more information about mapping local paths to the virtual machine running the Docker daemon when using Docker on Windows or macOS, refer to Virtual machine path mappings for Windows and macOS hosts. You will not be able to use volumes and bind mounts for directories outside of the mapped local path.

    This table is not available on a Linux host, where Docker runs natively and you can mount any directory to the container.

  3. Open the Services tool window ( View | Tool Windows | Services or Alt+8), select the configured Docker connection node Docker node and click The Connect button, or select Connect from the context menu.

    The Docker tool window, connected to Docker

    To edit the Docker connection settings, select the Docker node and click The Edit Configuration button on the toolbar, or select Edit Configuration from the context menu.

    You can also click the Add Service menu and select Docker Connection to add a Docker connection directly from the Services tool window. If you have Docker contexts configured, you can select Docker Connections from Docker Contexts to add the corresponding connections.

Once you connect to the Docker daemon, you can use the Services tool window ( View | Tool Windows | Services or Alt+8) to manage everything related to Docker, for example: pull and push images, create and run containers, and scale Docker Compose services. As with other tool windows, you can start typing the name of an image or container to highlight the matching items.

The Docker tool window, text search

For more information, refer to the section about Docker in Services tool window.

Working with Docker on a remote server

Prerequisites

Before you start working with Docker on a remote machine, make sure the following prerequisites are met:

  • A local Docker CLI, which is necessary for connecting to the remote Docker instance. You can either install Docker Desktop or just Docker CLI.

  • Docker Buildx plugin, which is necessary for building images from Dockerfile. Note that using Buildx with Docker requires Docker Engine version 19.03 or later.

Let's say you connected to your remote project using the SSH connection. Then you added a devcontainer.json and tried to create a dev container via Create Dev Container and Mount sources on the remote machine.

Currently, we don't support such scenario and you can't create a dev container from the running backend-client connection. If you have the corresponding gutter option in your remote project, please add your vote or comment to the corresponding issue.

Use the following procedure as workaround:

Create a dev container on the remote machine

  1. Create a Docker connection to SSH.

  2. Install locally the Docker CLI. On Windows, you can install it without the Docker desktop, we don't need the Docker daemon, we need only Docker CLI.

  3. Commit all changes from the SSH machine to Git.

  4. Create a dev container via JetBrains Gateway using the git clone command in the Welcome screen.

Last modified: 27 May 2024