You can add Docker
support to IntelliJ IDEA
by installing the Docker integration plugin.
- Prerequisite
- Overview of Docker support
- Working with Docker: Process overview
- Example: Deploying a web app into the Wildfly Docker container
Prerequisite
The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
Overview of Docker support
The Docker integration plugin adds the following to IntelliJ IDEA:
- Docker configurations. These are named sets of settings for accessing the Docker Remote API.
- Docker Deployment run/debug configurations. They let you download and build Docker images, create and start Docker containers , and deploy your application artifacts into the containers . Application debugging is supported only for Java.
- Docker-specific features in the Application Servers tool window. You can create, start, inspect, stop and delete your Docker containers, deploy your application artifacts, delete unnecessary Docker images, view logs and more.
Working with Docker: Process overview
-
Install Docker and start the Docker daemon
(on Windows and OS X - along with the Docker VM in which it runs).
For corresponding instructions,
see Get Started with Docker
.
-
Install the Docker integration plugin. For instructions, see Installing, Updating and Uninstalling Repository Plugins.
Note: For the plugin to work properly, IntelliJ IDEA should be started using Java 7 or a later version.
-
Create a Docker configuration.
You can do that:
-
Separately, in the Settings dialog:
Ctrl+Alt+S
. -
When creating a Docker Deployment run configuration:
, etc.
See the settings for a Docker configuration.
-
Separately, in the Settings dialog:
Ctrl+Alt+S
- Create an artifact configuration for your application.
- Build the artifact. You can do that separately (), or when executing the corresponding run configuration.
- Create a Docker Deployment run configuration.
- Execute the run configuration.
- Use the Application Servers Tool Window to manage your Docker images, containers and deployed applications.
Example: Deploying a web app into the Wildfly Docker container
Once you have installed Docker and the Docker integration plugin, you can try out some of the Docker integration features.
In this example, we'll use the
Wildfly app server Docker image
to create a container and deploy a one-page JSP application into that container.
-
Create a project for developing a Java web application
(, etc.),
see e.g Enabling Web app development support when creating a project or module.

-
When the project is created,
add text (e.g.
Hello World!) toindex.jsp, see e.g. Developing source code.
-
Create a Docker configuration and specify Docker API settings:
- Open the Clouds page of the Settings dialog: .
-
Click
and select Docker.
The default settings provided by IntelliJ IDEA should be OK (
https://192.168.99.100:2376for API URL and<your_home_directory>\.docker\machine\certsfor the certificates folder).
- Click OK in the Settings dialog.
-
In the project root directory, create a new directory (e.g.
docker-dir): , etc.We'll use this directory to store our
Dockerfile, a.warapplication artifact and a container settings file. -
Create a file
Dockerfilein thedocker-dirdirectory. -
Add the following to your Dockerfile
(this is what the file should contain according to the Wildfly image description):
FROM jboss/wildfly ADD <artifact-name>.war /opt/jboss/wildfly/standalone/deployments/
Use the actual artifact name in place of <artifact-name>.

-
Create an artifact configuration for your <artifact-name>.war:
- Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S) and select Artifacts.
-
Click
, select Web Application: Archive and
select For '<project-name>:war exploded'. -
Change the artifact name (in the Name field).
The name should be the same as in your
Dockerfile(<artifact-name>) but without.warat the end. -
Select the
docker-dirdirectory as the artifact output directory (the Output directory field.) (According to the Wildfly image description, the application.warartifact should be in the same directory as theDockerfile.)
- Click OK in the Project Structure dialog.
-
Create a Docker Deployment run/debug configuration and specify its settings:
-
. - Server. Select your Docker configuration.
- Deployment.
Select docker-dir/Dockerfile.
This means that the application deployment will be controlled by
the corresponding
Dockerfile. - Before launch.
Click
, select Build Artifacts, and
select your <artifact-name>artifact.
- Select the Container tab.
-
JSON file.
Generate a sample container settings
.jsonfile and save it indocker-dir: click
,
select docker-dirand click OK.
The rest of the settings are optional.
- Click OK in the Run/Debug Configurations dialog.
-
-
Open
container-settings.jsonin the editor. Note this fragment:"HostConfig": { "PortBindings":{ "8080/tcp": [{ "HostIp": "0.0.0.0", "HostPort": "18080" }] } }
This means that the TCP port 8080 inside the container will be available to the outside world as the port 18080.
-
Execute the run/debug configuration, e.g. by clicking
to the right of the run configuration selector.

Wait while IntelliJ IDEA downloads and builds the Wildfly image, creates and starts the container, and deploys the artifact into the container. (The Application Server tool window opens and corresponding info is output there.)

-
When the artifact is finally deployed,
open a web browser and go to
http://192.168.99.100:18080/<artifact-name>/to see the application output.
-
To get an impression of what other functionality is available,
look at context menu commands for various items in the Application Servers tool window.

Note that you can also run Bash
dockercommands. On OS X and Linux you can use the IntelliJ IDEA Terminal tool window for that. On Windows you should use the Bash command-line interpreter available in the Docker Toolbox.