Docker Compose. Port is assigned but when I netstat it shows nothing

I’ve no idea why this is happening and I am not good at asking questions.

It was fine a week ago after someone pushed this problem occured.

We are using Gitlab. just in-case.

Here is Docker Compose

services:
  backend-app:
    image: backend-app:latest
    build:
      context: .
    container_name: mdm_backend_app
    ports:
      - "8080:8080"
    networks:
      - app-network
    environment:
      - staticHesXmlPath=/mnt/clouhes
    volumes:
      #- ~/files/logs:/mnt/clouhes
      - ~/files/:/files/
      - /home/user/clouhes:/mnt/clouhes
    logging:
      driver: "json-file"
      options:
        max-size: "20m"
        max-file: "5"
    restart: unless-stopped

networks:
  app-network:
    driver: bridge

And Dockerfile

FROM maven:3.8.4-openjdk-17 AS build

WORKDIR /app

COPY . .

RUN mvn clean package -DskipTests

FROM openjdk:17-jdk-alpine
RUN apk add --no-cache tzdata
ENV TZ=World/Nowhere
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app

COPY --from=build /app/target/backend-0.0.1-SNAPSHOT.jar app.jar
RUN mkdir -p /logs
RUN mkdir -p /files
EXPOSE 8080

ENTRYPOINT ["java", "-jar", "/app/app.jar", "--spring.profiles.active=test"]

And when I try docker ps -a it shows 8080 port is mapped

CONTAINER ID   IMAGE                           COMMAND                  CREATED       STATUS       PORTS                                       NAMES
2338761f2a68   backend-app-image:latest    "java -jar /app/app.…"   2 hours ago   Up 2 hours   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp   backend_app

Then when I try to access 8080 it’s not working and after that I tried Netstat inside the Container and I am getting Nothing

user@ubuntu:~$ docker exec -it backend_app netstat -tulpn | grep 8080
user@ubuntu:~$

Is there something Wrong? I’ve no idea quite literally. I almost tried everything i knew. probably Enviroment Error? or something? First Time occuring.

The App is working just as intended on the background. but I can’t access it since the port is not assigned?

And I’ve seen the Log. Just in case here it is.

docker logs 2338761f2a68

  .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _    
( ( )___ | '_ | '_| | '_ / _` |    
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |___, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.3)

2025-02-24 15:54:59 - Starting BackendApplication v0.0.1-SNAPSHOT using Java 17-ea with PID 1 (/app/app.jar started by root in /app)
2025-02-24 15:54:59 - The following 1 profile is active: "test"
2025-02-24 15:55:00 - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2025-02-24 15:55:01 - Finished Spring Data repository scanning in 194 ms. Found 24 JPA repository interfaces.
2025-02-24 15:55:01 - Bean 'webServiceConfigSoap' of type [com.backend.backend.addons.smart_meter.config.WebServiceConfigSoap$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [annotationActionEndpointMapping]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2025-02-24 15:55:01 - Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [annotationActionEndpointMapping] is declared through a non-static factory method on that class; consider declaring it as static instead.
2025-02-24 15:55:01 - Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2025-02-24 15:55:02 - Tomcat initialized with port 8080 (http)
2025-02-24 15:55:02 - Initializing ProtocolHandler ["http-nio-0.0.0.0-8080"]
2025-02-24 15:55:02 - Starting service [Tomcat]
2025-02-24 15:55:02 - Starting Servlet engine: [Apache Tomcat/10.1.28]
2025-02-24 15:55:02 - Initializing Spring embedded WebApplicationContext
2025-02-24 15:55:02 - Root WebApplicationContext: initialization completed in 3587 ms
2025-02-24 15:55:03 - HHH000204: Processing PersistenceUnitInfo [name: default]
2025-02-24 15:55:03 - HHH000412: Hibernate ORM core version 6.5.2.Final
2025-02-24 15:55:03 - HHH000026: Second-level cache disabled
2025-02-24 15:55:04 - No LoadTimeWeaver setup: ignoring JPA class transformer
2025-02-24 15:55:04 - HikariPool-1 - Starting...
2025-02-24 15:55:04 - HikariPool-1 - Added connection ConnectionID:1 ClientConnectionId: 724e6471-73dc-407c-ae8d-a58dcdac8923
2025-02-24 15:55:04 - HikariPool-1 - Start completed.
2025-02-24 15:55:07 - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2025-02-24 15:55:07 - Initialized JPA EntityManagerFactory for persistence unit 'default'
2025-02-24 15:55:08 - Hibernate is in classpath; If applicable, HQL parser will be used.
2025-02-24 15:55:08 - Successfully executed sql script.
2025-02-24 15:55:10 - Resolved watchPath: /mnt/clouhes
2025-02-24 15:55:10 - folderToWatch path: /mnt/clouhes
2025-02-24 15:55:10 - archiveFolder path: /mnt/clouhes/archived
2025-02-24 15:55:10 - Directory already exists: /mnt/clouhes
2025-02-24 15:55:10 - Directory already exists: /mnt/clouhes/archived
2025-02-24 15:55:10 - Processing existing XML files in: /mnt/clouhes

Well… Anyone got solution?

And there is a around way to fix this.

I can just use Docker without Compose. and run it with

sudo -S docker run -d -p 8080:8080 --name backend_app backend-backend-app

In this case it works as intended Port is mapped and all.

user@ubuntu:~/.ECM/mdm-backend$ docker exec -it mdm_backend_app netstat -tulpn | grep 8080
tcp        0      0 :::8080                 :::*                    LISTEN      1/java

But it’s not what I want.

I need

    environment:
      - staticHesXmlPath=/mnt/clouhes
    volumes:
      #- ~/files/logs:/mnt/clouhes
      - ~/files/:/files/
      - /home/user/clouhes:/mnt/clouhes

This Syncs 2 Folders and Load XML Files.

Anyone got good solution here? or I just gotta use Docker without compose?

Well. Why is the Port not assigned inside the Container when I use Docker Compose.
I need to find out the issue here and fix it.

In short I need to Assign 8080 port to Container when I am using Docker Compose.