Building WildFly Docker Image

Building a Custom Container

A custom Docker image can be built on top of the platform AlmaLinux 9 base template. This guide uses WildFly as an example and covers Dockerfile preparation, image build and upload, and deployment through the platform topology wizard.

Compose the Dockerfile

Create an empty Dockerfile and add the following instructions in order.

1

Set the base image

Use the platform AlmaLinux 9 base template.

FROM jelasticdocker/almalinuxbase:latest
2

Define metadata and variables

LABEL maintainer="Virtuozzo International GmbH."
ENV WILDFLY_VERSION=36.0.0.Final
ENV ADMIN_USER=admin
ENV ADMIN_PASSWORD=admin
3

Install required packages

RUN dnf -y install java-17-openjdk-devel tar && dnf -y update
4

Download and extract WildFly

RUN cd /opt && curl -LO https://github.com/wildfly/wildfly/releases/download/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz \
    && tar xf wildfly-${WILDFLY_VERSION}.tar.gz \
    && rm wildfly-${WILDFLY_VERSION}.tar.gz
5

Create the WildFly link

RUN ln -s /opt/wildfly-$WILDFLY_VERSION /opt/wildfly
6

Create the service configuration

RUN echo -en "WILDFLY_SH=/opt/wildfly/bin/standalone.sh\n\
WILDFLY_SERVER_CONFIG=standalone.xml\n\
WILDFLY_CONSOLE_LOG=/var/log/wildfly/console.log\n\
WILDFLY_OPTS=\"-b 0.0.0.0 -bmanagement=0.0.0.0 -Djboss.management.http.port=4949 -Djboss.management.https.port=4848 -Djboss.server.log.dir=/var/log/wildfly/\"\n" >> /etc/sysconfig/wildfly-standalone.conf
7

Install and enable the systemd service

RUN cp /opt/wildfly-$WILDFLY_VERSION/bin/systemd/wildfly-standalone.service /etc/systemd/system/wildfly.service
RUN systemctl enable wildfly && mkdir -p /var/log/wildfly && adduser wildfly && \
    chown -R wildfly:wildfly /opt/wildfly-$WILDFLY_VERSION /opt/wildfly /var/log/wildfly
!

Change the credentials

The documented example uses admin/admin. Replace these values with secure credentials before production use.

8

Create the administration user

RUN /opt/wildfly/bin/add-user.sh --user $ADMIN_USER --password $ADMIN_PASSWORD --silent --enable
9

Add locale, ports, and entry point

RUN localedef -i en_US -f UTF-8 en_US.UTF-8
EXPOSE 22 80 443 8080 8743 9990 9993 8009 4848 4949
ENTRYPOINT ["/bin/bash"]

Build and Push the Image

Install Docker CE on the build machine before running these commands.

sudo docker build -t {image_name} {dockerfile_location}
sudo docker images
sudo docker push {image_name}
Build a custom Docker image
Build the custom image locally and verify that it appears in the image list.

Registry login

Use docker login before pushing when authentication is required.

Deploy the Custom Image

1

Open the Custom tab

Click New Environment, open Custom, and click Select Image.

Add a new custom image
Open the custom image selector in the topology wizard.
2

Add the image identifier

Use the following format. For a private repository, also enter the repository credentials.

[{registry_hostname}/]{account_namespace}/{image_name}
3

Select and deploy the image

Add the saved image to the required layer, complete the environment settings, and create the environment.

4

Open the container

Click Open in Browser. The WildFly start page confirms that the container is operational.

Expected Result

A custom WildFly image is built from the platform AlmaLinux 9 base template, uploaded to a registry, added to the platform custom-image list, and deployed as a working application-server container.

Important Notes

  • The source example uses WildFly 36.0.0.Final and OpenJDK 17.
  • Use secure administration credentials.
  • Private repositories require valid credentials.
  • Expose all required application and management ports.
  • Replace the self-signed certificate with a trusted certificate for production use.