In this example, a one-page JSP application is deployed into a
Wildfly app server image
-based container.
1. Develop the app
-
Create a project for developing a Java web application:
, etc.

-
When the project is created,
add text (e.g.
Hello World!) toindex.jsp, see e.g. Developing source code.
2. Specify deployment info in a Dockerfile
-
In the project root directory, create a new directory (e.g.
docker-dir): .We'll use this directory to store our
Dockerfileand a.warapplication artifact. -
In the
docker-dirdirectory, create aDockerfile. -
Add the following to your
Dockerfile:FROM jboss/wildfly COPY <artifact-name>.war /opt/jboss/wildfly/standalone/deployments/
Use the actual artifact name in place of
<artifact-name>. On the following picture, the name of the artifact isHelloDocker.
This Dockerfile sets jboss/wildfly as the base image and copies the local file <artifact-name>.war located in the same as the Dockerfile directory to the server deployment directory
/opt/jboss/wildfly/standalone/
deployments/.
3. Configure a WAR artifact
- Open the Project Structure dialog (e.g. ⌘;⌘;⌘;⌃⌥⇧S⌃⌥⇧S) and select Artifacts.
-
Click
, select Web Application: Archive and
select For '<project-name>:war exploded'.
-
Change the artifact name.
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.
- Click OK in the Project Structure dialog.
4. Build the artifact
- Select .
5. Run your Dockerfile
-
In your
Dockerfile, click
and
select Run on 'Docker'.
6. Map the container http port 8080 onto a host port
-
Open the run configuration associated with your
Dockerfilefor editing:
. -
Select the Container tab,
expand the Port bindings section, and
click
to create a new port mapping.You can also add the corresponding Build artifact task to the Before launch task list. Then, your WAR artifact will be built automatically each time you execute the run configuration.
-
In the dialog that opens, specify:
- Container port:
8080 - Protocol:
tcp - Host IP:
0.0.0.0 - Host port:
18080

- Container port:
- Click Run.
7. Check the application output in a browser
When the container is started, open a web browser and go to:
-
If you are using Docker for Windows, macOS or Linux:
http://localhost:18080/<artifact-name>/ -
If you are using the Docker Toolbox for Windows or macOS (deprecated):
http://192.168.99.100:18080/<artifact-name>/