Docker swarm with Glassfish 3.1.2.2 image fails to start nodes

We want to dockerize an application running on Glassfish 3.1.2.2 and use a docker swarm to run a few load - ballanced nodes of it. For this purpose I created a docker image based on this DockerFile:

FROM openjdk:7-jdk

ENV LANGUAGE=el_GR:el
lang=EL_gr.utf-8
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
GLASSFISH_HOME=/usr/local/glassfish3/glassfish
ENV GLASSFISH_DOMAIN1=$GLASSFISH_HOME/domains/domain1
GLASSFISH_BINARY_URL=http://download.oracle.com/glassfish/3.1.2.2/release/glassfish-3.1.2.2.zip
PATH=$PATH:$JAVA_HOME/bin:$GLASSFISH_HOME/bin

LABEL glassfish.version=“3.1.2.2” \
java=“openjdk-7”

RUN apt-get update && apt-get install -y curl unzip zip inotify-tools locales &&
rm -rf /var/lib/apt/lists/* &&
curl -L -o /tmp/glassfish.zip $GLASSFISH_BINARY_URL && \
unzip -q /tmp/glassfish.zip -d /usr/local &&
rm -f /tmp/glassfish.zip &&
cp $GLASSFISH_DOMAIN1/config/logging.properties $GLASSFISH_DOMAIN1/config/logging.properties.default &&
cp $GLASSFISH_DOMAIN1/config/login.conf $GLASSFISH_DOMAIN1/config/login.conf.default
EXPOSE 4848 8080 8181
CMD [“asadmin”, “start-domain”, “-v”]

I have tested the image and it works fine:

$docker build -t glass3 --tag myname/glassfish:3.1.2.2 .
$docker run --rm --name glass -p 8080:8080 -p 4848:4848 glass3

Navigate to localhost:4848 or 192.168.99.100:4848 to check the glassfish admin console is available

$docker stop glass

When I try to start a swarm (even with a single node) I get an error saying that port 4848 is already in use, although there is no process using that port:

$docker swarm init --advertise-addr 192.168.99.100
$docker service create --name glass-swarm -p 8080:8080 -p 4848:4848 myname/glassfish:3.1.2.2

$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4620018f8197 myname/glassfish “asadmin start-dom…” 2 seconds ago Created glass-swarm.1.neqktsvc41gkkpp4yubftydaq

$ docker logs -f 4620



There is a process already using the admin port 4848 – it probably is another instance of a GlassFish server.
Command start-domain failed.

I tried using other public images from Docker Hub like ucalgary/glassfish with the same outcome. This does not happen when I create a swarm based on Glassfish 4.1.1. Unfortunatelly our web app is only compatible with Glassfish 3.1.2.2

Any idea why this is happening?