JBoss/WildFly Application Server im Docker

Workdir

mkdir centos7-wildfly10.1.0
cd centos7-wildfly10.1.0
wget http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz
wget --no-cookies --header "Cookie:oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u102-b14/server-jre-8u102-linux-x64.tar.gz
vi Dockerfile

Dockerfile

FROM centos:7

# JAVA_URL=http://download.oracle.com/otn-pub/java/jdk/8u102-b14/server-jre-8u102-linux-x64.tar.gz
# JBOSS_URL=http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz

# Maintainer
MAINTAINER Michael Mende <wildfly-on-docker@failover.de>

ENV \
    JAVA_TGZ=server-jre-8u102-linux-x64.tar.gz \
    JAVA_HOME=/opt/java/default \
    \
    JBOSS_TGZ=wildfly-10.1.0.Final.tar.gz \
    JBOSS_HOME=/opt/jboss/default \
    \
    JBOSS_PASSWORD=wildfly

ENV  PATH=${JAVA_HOME}/bin:${PATH}
ENV  PATH=${JBOSS_HOME}/bin:${PATH}

# Install Java
# Install JBoss / Wildfly
RUN mkdir -pv /opt/java/ /opt/jboss

ADD ./$JAVA_TGZ /opt/java/
ADD ./$JBOSS_TGZ /opt/jboss/

RUN \
    useradd -d $JBOSS_HOME -M -s /bin/false jboss && \
    ln -sv $(ls -d /opt/java/*) $JAVA_HOME && \
    ln -sv $(ls -d /opt/jboss/*) $JBOSS_HOME && \
    chmod 0750 /opt/jboss/* && \
    chown -R jboss:jboss /opt/jboss/*

# Switch to Glassfish Runtime User
USER jboss

# Change Glassfish admin password
RUN $JBOSS_HOME/bin/add-user.sh -u admin -p "$JBOSS_PASSWORD" -s
RUN sed -i -e "s/jboss.bind.address.management:127.0.0.1/jboss.bind.address.management:0.0.0.0/" -e "s/jboss.bind.address:127.0.0.1/jboss.bind.address:0.0.0.0/" $JBOSS_HOME/standalone/configuration/standalone.xml

# Glassfish-Ports
EXPOSE 8080 8443 9990

# Start asadmin console and the domain
ENTRYPOINT ["standalone.sh"]

Build

docker build  -t centos7/wildfly:10.1.0 .

Run

docker run --name=centos-wildfly10 -p 18443:8443 -p 18080:8080 -p 19990:9990 centos7/wildfly:10.1.0

Commit

docker commit centos-wildfly10

Restart

docker stop centos-wildfly10
docker start centos-wildfly10