Docker and jboss

2015-10-23 22:37:02

First we have to download base wildfly images

to do this, execute this command:

sudo docker pull jboss/wildfly

After few minutes, when image will be on your disk, you can check if base wildfly images works correctly

to do this, execute this command:

sudo docker run -it --rm jboss/wildfly

if everything is OK you can go to browser and open wildfly "open page" but wait! first you have to check the ip address because the standard address "http://localhost:8080/" doesn't work

check the wildfly address

first you have to check CONTAINER ID of docker container

sudo docker ps

you should receive something like this:

CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS               NAMES
8f98b781c568        jboss/wildfly       "/opt/jboss/wildfly/b"   About a minute ago   Up About a minute   8080/tcp            agitated_varahamihira

now, when you have CONTAINER ID, you can run this command

sudo docker inspect 8f98b781c568

to display all interesting information about Docker container in JSON format

    "Id": "8f98b781c5680f8cc25254e00e30b620fcb109f8fa042ad03d84a62bd005db64",
    "Created": "2015-10-23T21:32:29.873704281Z",
    "Path": "/opt/jboss/wildfly/bin/standalone.sh",
    "Args": [
    "State": {
        "Running": true,
        "Paused": false,
        "Restarting": false,
        "OOMKilled": false,
        "Dead": false,
        "Pid": 18026,
        "ExitCode": 0,
        "Error": "",
        "StartedAt": "2015-10-23T21:32:30.058782686Z",
        "FinishedAt": "0001-01-01T00:00:00Z"
    "Image": "d378c79af2ae12420e5e02d38633f683fd2c87b7661206ecc50b5b122111a340",
    "NetworkSettings": {
        "Bridge": "",
        "EndpointID": "df396473030d3e7cbe615a73e89ab047264249db9407ef8e1cbb9d6970c12361",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,

try to find IP in NetworkSettings - > IPAddress, in my case it is

having that information you can open Jboss "Open Page" by ""

this is not the base way

you have to admit, this is not the base way, if you have to searching to find this IP, you can adjust this by

sudo docker run -it --rm -p 8080:8080 jboss/wildfly

by adding this part -p 8080:8080, now, our jboss server is exposed on http://localhost:8080/ awesome!

time for deploy the app

ok we have jboss running, now we have to deploy something, we can do this by Jboss Administration Console.

On the Jboss "Open Page" you will find the link

ah it doesn't work

why ? because by default (security reasons) jboss doesn't has any users, you have to create them

creating new docker image with jboss user

  1. create directory for example "docker-image-firs"
  2. create file "Dockerfile" in that directory
  3. add conntent to file
FROM jboss/wildfly:latest
RUN /opt/jboss/wildfly/bin/add-user.sh USER PASSWORD --silent
  1. save the file, and execut this command:
sudo docker build -t szalek/jboss/wildfly/user .

Awesome!, do you know what you just did ? you have just created new docker image

now you can execute this command:

sudo docker run -it --rm -p 8080:8080 -p 9990:9990 szalek/jboss/wildfly/user /opt/jboss/wildfly/bin/standalone.sh -b -bmanagement

now Jboss Administration Console is available, and you can deploy your app

simple JEE app

  1. in your IDE create new Maven project
  2. use this pom.xml
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>

<project http:="" maven-4.0.0.xsd&quot;="" maven.apache.org="" xmlns='"http://maven.apache.org/POM/4.0.0"' xmlns:xsi='"http://www.w3.org/2001/XMLSchema-instance"' xsd="" xsi:schemalocation='"http://maven.apache.org/POM/4.0.0'>

  1. create two java class


package pl.btbw.core;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

public class MyApp extends Application {


package pl.btbw.web;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;

public class MyCtrl {

    public Map

<string, object=""> doTest() {

        Map<string, object=""> map = new HashMap&lt;&gt;();
        map.put("ID", 1);
        map.put("TITLE", "LOREM");

        return map;