Building Custom Container
Building Custom Container
Compose Dockerfile
Create an empty Dockerfile and add the required instructions. The following example uses the platform AlmaLinux 9 base image and WildFly 36.
1. Select the Base Image
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
LABELdefines image metadata.WILDFLY_VERSIONspecifies the release to install.ADMIN_USERandADMIN_PASSWORDdefine the initial administration credentials.
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 a Short Symlink
RUN ln -s /opt/wildfly-$WILDFLY_VERSION /opt/wildfly
6. Add WildFly Runtime 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 the systemd Service
RUN cp /opt/wildfly-$WILDFLY_VERSION/bin/systemd/wildfly-standalone.service /etc/systemd/system/wildfly.service
8. Enable the Service and Set Permissions
RUN systemctl enable wildfly && mkdir -p /var/log/wildfly && adduser wildfly && \
chown -R wildfly:wildfly /opt/wildfly-$WILDFLY_VERSION /opt/wildfly /var/log/wildfly
9. Generate a Self-Signed Administration Certificate
RUN cd /opt/wildfly/standalone/configuration && \
keypass=password; keytool -genkeypair -alias serverkey -keyalg RSA -keysize 4096 -validity 7360 \
-keystore application.keystore -keypass $keypass -storepass $keypass -dname "cn=Server Administrator,o=Acme,c=GB" && \
chown wildfly:wildfly application.keystore && \
xmlstarlet ed -L -N s="urn:jboss:domain:community:20.0" -i "s:server/s:management/s:management-interfaces/s:http-interface/s:socket-binding" -t attr -n https -v "management-https" standalone.xml && \
xmlstarlet ed -L -N s="urn:jboss:domain:community:20.0" -i "s:server/s:management/s:management-interfaces/s:http-interface" -t attr -n ssl-context -v "applicationSSC" standalone.xml
10. Create the WildFly Administrator
RUN /opt/wildfly/bin/add-user.sh --user $ADMIN_USER --password $ADMIN_PASSWORD --silent --enable
11. Configure the Administration Console Link
RUN sed -i "s/<a href=\"\/console\">/<a href=\"\/console\" onclick=\"javascript:event.target.port=4848;event.target.protocol=\'http:\';\">/" /opt/wildfly/welcome-content/index.html
12. Add the English Locale
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
13. Expose Required Ports
EXPOSE 22 80 443 8080 8743 9990 9993 8009 4848 4949
14. Define the Entry Point
ENTRYPOINT ["/bin/bash"]
admin/admin credentials and self-signed certificate with secure production values before using the image publicly.
Add Image to Repository
Install a compatible Docker CE version on the build machine before running the following commands.
1. Build the Image
sudo docker build -t {image_name} {dockerfile_location}
{image_name}— repository name, optionally including a tag, such asexamplerepo/wildfly:latest.{dockerfile_location}— local path or URL; use.when the Dockerfile is in the current directory.
2. Verify the Local Image
sudo docker images
3. Push the Image
sudo docker push {image_name}
Use the same image name that was specified during the build. Authenticate with the registry when prompted, or run docker login beforehand.
Deploy Image
1Open custom image selection
Click New Environment, open the Custom tab, click Select Image, choose the required environment layer, and click Add New Image.
2Enter the image identifier
Use the format [{registry_hostname}/]{account_namespace}/{image_name}. Omit the registry hostname when Docker Hub is used. Supply a username and password for a private repository.
3Add the image to the topology
Select the saved image from the custom list, finish the environment configuration, and create the environment.
4Open the deployed application
After provisioning is complete, click Open in Browser. When the image is placed outside the Application Servers or Balancing layers, use the button beside the individual container.
