Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to run a wildfly server inside docker

Before we begin you must configure docker, I am using Ubuntu so I followed the guide here: https://docs.docker.com/engine/installation/linux/ubuntulinux/. Choose the appropriate OS that applies to you.

Let's do this in sequence:

  1. Checkout and compile the very basic javaee war from https://github.com/czetsuya/hello-javaee.
  2. In Ubuntu create a new folder: wildfly-hello:
    >mkdir wildfly-hello
  3. Copy hello-javaee.war inside wildfly-hello.
  4. Create a Dockerfile and insert the lines below inside the same folder.

    from jboss/wildfly
    run /opt/jboss/wildfly/bin/add-user.sh admin admin@1234 --silent
    add hello-javaee.war /opt/jboss/wildfly/standalone/deployments/
    cmd ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
  5. Inside the wildfly-hello folder build the Dockerfile.
    >docker build -it wildfly-hello .
  6. Run the docker image
    >docker run wildfly-hello
  7. Get the ip address of the container by:
    >docker ps - to get the container id
    >docker inspect -f '{{ .NetworkSettings.IPAddress }}' CONTAINER_ID
  8. Now we should have the ip address of docker, we can now open wildfly in the browser.
What does the lines in step 3 means?
-from is a docker keyword use to import an image from docker hub hub.docker.com
-run is a command that runs an executable file, in this case we are adding a user with application management role
-add lets us add a file inside the container
-cmd tells the docker to execute this by default, when we execute docker run
How to run a wildfly server inside docker How to run a wildfly server inside docker Reviewed by Edward Legaspi on Friday, December 16, 2016 Rating: 5

No comments:

Powered by Blogger.