Build process from .war file seems not working via docker-compose.yaml?

Hi,

I have the following structure in my app:

My file structure is like:
image

The Dockerfile looks like:

FROM quay.io/wildfly/wildfly:26.1.3.Final-jdk11

RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent


COPY my-standalone.xml /opt/jboss/wildfly/standalone/configuration/
COPY myapp.war /opt/jboss/wildfly/standalone/deployments/
COPY module.xml /opt/jboss/wildfly/modules/system/layers/base/com/mysql/main/
COPY mysql-connector-java-8.0.12.jar /opt/jboss/wildfly/modules/system/layers/base/com/mysql/main/

EXPOSE 8080 9990

# Run with custom configuration
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0", "-c","my-standalone.xml"]

The docker-compose.yaml:

version: "2"

services:
  app:
    container_name: "app"
    image: "myapp"
    environment:
      - WILDFLY_USER=admin
      - WILDFLY_PASS=adminPassword
      - DB_NAME=myapp
      - DB_USER=root
      - DB_PASS=test1234
      - DB_URI=jdbc:mysql://host.docker.internal:3306/myapp?serverTimezone=Europe/Berlin&useSSL=false
    build: ./myapp
    restart: always
    depends_on:
      - db
    volumes:
      - ~/deployments:/opt/jboss/wildfly/standalone/deployments
    ports:
      - "8080:8080" # application
      - "9990:9990" # admin console

  db:
    container_name: "db"
    image: "mysql:latest"
    environment:
      - MYSQL_DATABASE=myapp
      - MYSQL_USER=root
      - MYSQL_PASSWORD=test1234
      - MYSQL_ROOT_PASSWORD=test1234
    volumes:
      - ./workdir/db/init/:/docker-entrypoint-initdb.d/ # init database
      - ./workdir/db/data/:/var/lib/mysql/              # data storage
    ports:
      - "3307:3307"

networks:
    default:
        driver: bridge

If I start docker, everything is green.

If I go to: http://localhost:8080/ it seems WildFly is started, but if I start my app like:
http://localhost:8080/test.jsf the page is not found. So it seems the .war file was not deployed.

If I use only the Dockerfile and deploy it (not docker-compose), I´m able to start WildFly and use also the webapp.

What´s wrong?

host.docker.internal is only available on Docker Desktop installs.

The way to go is to create a Docker network and attach all services to it. Only expose ports of the one you want to be available on the Internet. Connect to DB using the service name.

Share your working Docker CLI command you use :slight_smile: