How to start a Docker image of WildFly with an application deployed

Serving a Docker container with a non default image of WildFly is pretty easy. Say that you have a folder named build with an application demoapp.war deployed on it. Then you can create a Dockerfile which merely adds the Web application to the deployments folder of your server. Then use the CMD command to start WildFly with the required configuration and bindings:

FROM jboss/wildfly
ADD build/demoapp.war "/opt/jboss/wildfly-10.0.0.Final/standalone/deployments/demoapp.war"
# Start WildFly using the HA Profile
CMD ["/opt/jboss/wildfly-10.0.0.Final/bin/", "-c","standalone-ha.xml","-b", "","-bmanagement",""]

Build your image with a meaningful tag name:

$ sudo docker build --rm -t jboss/wildfly/custom .

Once the image has completed building, you can run it. In order to run the image, you will need to reference it by its name, which in our case is jboss/wildfly/custom:

$ sudo docker run -it jboss/wildfly/custom


Follow us on Twitter