Docker Image for JBoss EAP
Following post explains how to create Docker Image for JBoss EAP and expose its management and web 8080 port for access from host machine or other applications.
Before proceeding with this article you should have Docker and Docker Machine installed on your machine.
You can also refer to my previous post on how to create simple java post.
Dockerfile
Create a similar Docker file. This file is available at following Github repo - tuhingupta/docker-jboss-eap.
If you look at the dockerfile, you will notice:
at line 1, we start with FROM key word. This tells Docker what image to use as base image.
at line 2, we specify MAINTAINER that tells the name, email of the person maintaining the image
at line 4, WORKDIR specifies the working directory in the image.
at line 5, RUN keyword runs whatever command proceeds it.
at line 6, copy jboss-eap zip file to /usr/software folder in the image
at line 9, unzip jbos-eap zip
at line 15, setup user for jboss admin
at line 18, set JAVA_OPT . We need to bind address and management console address so that EAP will bind on all IP addresses for our container.
at line 21, EXPOSE command is used to expose ports from the container.
at line 26, ENTRYPOINT command tells what command will run when the container starts.
Save this file as Dockerfile in a folder that also contains jboss-eap-6.2.4.zip file.
Building the container
Now you build the image using the following command:
$ docker build --rm -f Dockerfile -t jboss-eap .
Once the image is built, it is ready to be run.
Run docker image
Run the docker image
$ docker run -it -p 0.0.0.0:9990:9990 -p 0.0.0.0:8080:8080 --name jboss-serv -d jboss-eap
you will notice that we used -p option.
-p option publishes a container's port(s) to the host.
This option publishes the ip that we bind in line 18 of Dockerfile so that it can be accessed from host by using localhost.
Accessing JBoss URLs
Now you can access JBoss management console using
http://localhost:9990/management