1. Build a web app artifact
If you already have your web app in deployable format - as a WAR or a directory structure - you can skip this section and go to Running an app server image.
For web apps, IntelliJ IDEA provides deployment-ready
WAR
and Exploded (unzipped) WAR
artifact formats.
To build such artifacts:
-
Enable web app development support:
-
When creating a project:
or , etc. -
For an existing project:
In the Project tool window (View | Tool Windows | Project), right-click the corresponding module folder and select Add Framework Support. Then select the Web Application check box in the dialog that opens.
-
When creating a project:
-
Create artifact configurations for your app: .
-
Web Application: Exploded artifact configuration was
created automatically when you enabled web app development support.
Some servers are unable to deploy exploded WAR artifacts.
-
Web Application: Archive (WAR) artifact configuration.
To create such an artifact configuration:
.
Then click Create Manifest and
accept the default location .../webforMETA-INF/MANIFEST.MF.
-
Web Application: Exploded artifact configuration was
created automatically when you enabled web app development support.
- Build the artifact: Build | Build Artifacts | <ArtifactName> | Build. Alternatively, you can include the Build artifact task in the Before launch task list in your Docker Deployment run configuration.
For more info on web application development and related artifacts, see the Developing a Java EE Application tutorial.
2. Run an app server image
You can choose to run the app server image from your Dockerfile, or
you can pull and then run the image from the Docker tool window.
2a. Run the image from a Dockerfile
-
Create a
Dockerfileand open it in the editor. -
Type
FROM <app_server_image_name>:<tag>e.g.FROM tomcat:latest. -
Click
and select Run on 'Docker'.

As a result, a Docker Deployment run configuration is created, your image runs, and the corresponding container appears in the Docker tool window.
At a later time, you may want to make adjustments to your run configuration.
In such a case,
click
and
select Edit '<Configuration Name>'.

2b. Pull and then run the image from the Docker tool window
- In the Docker tool window (), right-click the Docker node and select Pull image.
-
To pull an image from Docker Hub
(registry.hub.docker.com), specify the image name in the Repository field, e.g.tomcat, and the image tag, e.g.latest.If pulling an image assumes user authentication, click New to create a Docker Registry configuration and specify your Docker image repository user account info.
-
When the image is downloaded, select it, and then
click
or
select Create container from the context menu. - In the Create container popup, click Create.
- In the dialog that opens, on the Deployment tab, if necessary, specify the name for the container that will be created.
- Click Run.
3. Deploy the app
You can deploy your web app by mapping the artifact folder to the app server deployment folder. You can as well deploy your app by copying the artifact to the deployment folder.
3a. Deploy the app by mapping the artifact output folder to the deployment folder
-
In the Docker tool window,
select your app server container, and then select the Volume Bindings tab.
Alternatively, you can specify the necessary mapping in your Docker Deployment run configuration.
To start editing the run configuration, select the container, and then click
or
select Edit Configuration from the context menu.
Then, to restart the container, click
or
select Redeploy from the context menu.
-
Click
to create a new binding. -
In the dialog that opens, specify:
-
Container path.
The path to server deployment folder, e.g.
/usr/local/tomcat/webappsfor Tomcat. - Host path. For a WAR artifact, the path to the artifact output directory; for an exploded WAR artifact, the path to the directory that contains the artifact output directory.

-
Container path.
The path to server deployment folder, e.g.
- To apply the changes, click Save.
-
To check the mapping, run the Inspect command for the container and
search the inspection result (Ctrl+F) for
HostConfig. You'll find the mapping of interest next to"Binds".
3b. Deploy the app by copying the artifact to the server deployment folder
-
Make sure that your artifact is in the same directory as your
Dockerfile. -
In your
Dockerfile, on the line that followsFROM <app_server_image_name>:<tag>, e.g.FROM tomcat:latest, add:-
For an exploded artifact:
COPY . </server/deployment/path>, e.g.COPY . /usr/local/tomcat/webappsfor Tomcat. -
For a WAR artifact:
COPY <artifactname>.war </server/deployment/path>
-
For an exploded artifact:
-
Click
and select Run '<ConfigurationName>'.

4. Map the container http port onto a host port
-
Though the http server port is usually 8080, make sure that this is the case:
In the Docker tool window, right-click your app server container and select Inspect. Search the inspection result (Ctrl+F) forExposedPortsto see which port is being used.Alternatively, you can specify this mapping in your Docker Deployment run configuration.
Use:
to start editing the run configuration.
to restart the container after specifying the mapping.
-
Make the container http port available on the host:
Select the Port Bindings tab. You can choose to specify the host port yourself, or let Docker decide which port should be used. So, do one of the following:-
Click
and specify the mapping.
To make the port accessible only from your localhost, for Host IP,
specify localhostor127.0.0.1. To make the port accessible from other computers on your network as well, specify0.0.0.0. To apply the changes, click Save. -
Select the Publish all ports check box and click Save.
Now, you need to find out which host port is mapped to the container http port. To do that, run the Inspect command for the container. Then search the inspection result (Ctrl+F) forNetworkSettings. The"Ports"subsection will include the info about your http host port.
-
Click
5. Check the application output in a web browser
To see the application output, open a web browser and go to:
-
http://localhost:<host-port>/<artifact-name>/if you are using Docker for Windows, macOS or Linux. -
http://192.168.99.100:<host-port>/<artifact-name>/if you are using Docker Toolbox for Windows or macOS (deprecated).
<host-port> is the host port mapped onto the container's http port.
<artifact-name>, by default, is the name of the .war file if you deployed your app as a WAR, or
the name of the app root directory if you deployed you app as a directory structure.