Docker plugin integration
Docker enables developers to deploy applications inside containers for testing code in an environment identical to production. CLion provides Docker support using the Docker plugin. The plugin is bundled and enabled by default .
Enable Docker support
Install and run Docker.
For more information, see the Docker documentation.
Configure the Docker daemon connection settings:
Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Docker.
Click
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, see Docker configuration.
The Connection successful message should appear at the bottom of the dialog.
note
The Path mappings table is used to map local folders to corresponding directories in the Docker virtual machine's file system. Only specified folders will be available for volume binding.
This table is not available on Linux, because when running Docker on Linux, any folder is available for volume binding.
Connect to the Docker daemon.
The configured Docker connection should appear in the Services tool window (View | Tool Windows | Services or Alt+8). Select the Docker node
and click
, or select Connect from the context menu.
To edit the Docker connection settings, select the Docker node and click
on the toolbar, or select Edit Configuration from the context menu.
In the Services tool window (View | Tool Windows | Services or Alt+8), you can pull and push images, create and run containers, manage Docker Compose services, and so on. As with other tool windows, you can start typing the name of an image or container to highlight the matching items.

Managing images
Docker images are executable packages for running containers. Depending on your development needs, you can use Docker for the following:
Images are distributed via the Docker registry. Docker Hub is the default public registry with all of the most common images: various Linux flavors, database management systems, web servers, runtime environments, and so on. There are other public and private Docker registries, and you can also deploy your own registry server.
CLion stores images that you pull or build locally and lists them in the Services tool window under Images. When you select an image, you can view its ID or copy it to the clipboard by clicking on the Properties tab.

To display detailed information about an image, right-click it and select Inspect from the context menu. CLion runs the docker image inspect command and prints the output to the Inspection tab.

Images with no tags <none>:<none>
can be one of the following:
Intermediate images that serve as layers for other images and do not 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 on the Docker toolbar, and then click Untagged Images to remove the check mark.
To delete one or several images, select them in the list and click .
Running containers
Docker containers are runtime instances of the corresponding images. CLion uses run configurations to execute the commands that build Docker images and run containers. There are three types of Docker run configurations:
Docker Image: Created automatically when you run a container from an existing image. You can run it from a locally existing Docker image that you either pulled or built previously.
Dockerfile: Created automatically when you run a container from a Dockerfile. This configuration builds an image from the Dockerfile, and then derives a container from this image.
Docker-compose: Created automatically when you run a multi-container Docker application from a Docker Compose file.
Docker run configurations
Create a Docker run configuration
From the main menu, select Run | Edit Configurations.
In the Run/Debug Configurations dialog, click
, point to Docker, and then click the desired type of run configuration.
Use this type of configuration to run a Docker container from a locally existing image that you either pulled or built previously.
Docker uses the docker run command with the following syntax:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
You can set all the arguments for this command using the options of the Docker Image run configuration.
By default, the Docker Image configuration has the following options:
Name | Specify a name for the run configuration to quickly identify it among others when editing or running. |
Allow parallel run | Allow running multiple instances of this run configuration in parallel. By default, it is disabled, and when you start this configuration while another instance is still running, CLion suggests stopping the running instance and starting another one. This is helpful when a run configuration consumes a lot of resources and there is no good reason to run multiple instances. |
Store as project file | Save the file with the run configuration settings to share it with other team members. The default location is .idea/runConfigurations. However, if you do not want to share the .idea directory, you can save the configuration to any other directory within the project. By default, it is disabled, and CLion stores run configuration settings in .idea/workspace.xml. |
Server | Select the Docker daemon connection to use for the run configuration. |
Image ID or name | Specify the identifier or the name of the Docker image from which to create the container. |
Container name | Specify an optional name for the container. If empty, Docker will generate a random name for the container. This is similar to using the |
Before launch | Specify a list of tasks to perform before starting the run configuration. For example, compile some code and build the necessary artifacts, run some external tool or a web browser, and so on. Click Move tasks in the list using Select a task an click |
Show this page | Show the run configuration settings before actually starting it. |
Activate tool window | Open the Services tool window when you start this run configuration. When disabled, you can open the tool window manually to see the running container: View | Tool Windows | Services or Alt+8. |
Use the Modify options menu to add advanced options to the run configuration:
Randomly publish all exposed ports | Publish all exposed container ports to random free ports on the host. This is similar to using the |
Bind ports | Map specific container ports to specific ports on the host. This is similar to using the Click Lets say you already have PostgreSQL running on the host port 5432, and you want to run another instance of PostgreSQL in a container and access it from the host via port 5433. Binding the host port 5433 to port 5432 in the container is similar to setting the following command-line option:
You can set this option explicitly in the Run options field instead of configuring the Bind ports field. |
Entrypoint | Override the default This is similar to using the |
Command | Override the default This is similar to adding the command as an argument for |
Bind mounts | Mount files and directories on the host to a specific location in the container. This is similar to using the
Click For example, you can mount a local PostgreSQL directory on the host (
You can set this option explicitly in the Run options field instead of configuring the Bind mounts field. |
Environment variables | Specify environment variables. There are environment variables associated with the base image that you are using as defined by the This is similar to using the Click For example, if you want to connect to PostgreSQL with a specific username by default (instead of the operating system name of the user running the application), you can set the
You can set this option explicitly in the Run options field instead of configuring the Environment variables field. |
Run options | Set any other supported docker run options. For example, to connect the container to the
|
Attach to container | Attach to the container's standard input, output, and error streams. This is similar to using the |
Show command preview | Preview the resulting command that will be used to execute the run configuration. |
Interacting with containers
Created containers are listed in the Services tool window. By default, the Services tool window displays all containers, including those that are not running. To hide stopped containers from the list, click in the toolbar, select Docker, and then click Stopped Containers to remove the checkbox.
When you select a container, you can view the following tabs by default:
Build Log | Shows the deployment log produced by the corresponding Docker run configuration while building the image for the container. |
Log | Shows the log messages from the container's standard output streams: For more information, see the docker logs command reference. |
Properties | Shows the name and ID of the container, and the ID of the corresponding image. To copy any property to the clipboard, select it and click You can also specify a new name for the container and click Save. If the container is running, it will stop and get a new name. To run the container with the new name, select it and click |
Environment Variables | Shows the environment variables configured for the container. To add a new variable, click When you make any changes and click Save, if the container is running, it will stop. To run this container with the new set of variables, select it and click |
Port Bindings | Show the port bindings configured for this container. Select Publish all ports to bind all exposed container ports to random free ports on the host. To add a new port binding, click When you make any changes and click Save, if the container is running, it will stop. To run this container with the new port bindings, select it and click |
Volume Bindings | Show the volume bindings configured for this container. To add a new volume binding, click When you make any changes and click Save, if the container is running, it will stop. To run this container with the new volume bindings, select it and click |
Files | Browse the files inside a running container. Select any file and click
|
Docker Compose
Docker Compose is used to run multi-container applications. For example, you can run a web server, a backend database, and your application code as separate services. Each service can be scaled by adding more containers if necessary. This enables you to perform efficient development and testing in a dynamic environment, similar to production.
Run a multi-container Docker application
Define necessary services in one or several Docker Compose files.
From the main menu, select Run | Edit Configurations.
Click
, point to Docker and then click Docker-compose.
Specify the Docker Compose files that define services which you want to run in containers. If necessary, you can restrict the services that this configuration will start, specify environment variables, and force building of images before starting corresponding containers (that is, add the
--build
option for the docker-compose up command).For more information about the available options, see Docker-compose.
Click OK to save the Docker Compose run configuration, select it in the main toolbar and click
or press Shift+F10 to start the configuration.
note
To quickly create a Docker-compose run configuration and run it with default settings, right-click a Docker Compose file in the Project tool window and click Run in the context menu. You can also use gutter icons and the context menu in the Docker Compose file to control services.
When Docker Compose runs your multi-container application, you can use the Services tool window to control specific services and interact with containers. The containers are listed under the dedicated Compose nodes, not under the Containers node (which is only for standalone containers).
The Docker-compose run configuration will identify environment files with the .env suffix if they are located in the same directory as the Docker Compose file.
Troubleshooting
If you encounter one of the following problems, try the corresponding suggested solution.
Limitations
The Docker plugin has certain limitations and bugs, however JetBrains is constantly working on fixes and improvements for it. You can find the list of Docker issues in our bug-tracking system and vote for the ones that affect you the most. You can also file your own bugs and feature requests.