Код: Выделить всё
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
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"]
< /code>
И когда я попробую Docker ps -a, показывает, что порт 8080 отображается < /p>
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
< /code>
Затем, когда я пытаюсь получить доступ к 8080, он не работает, и после этого я попробовал NetStat в контейнере и ничего не получаю < /p>
user@ubuntu:~$ docker exec -it backend_app netstat -tulpn | grep 8080
user@ubuntu:~$
< /code>
Есть ли что -то не так? Я понятия не имею, буквально. Я почти пробовал все, что знал. Наверное, ошибка среды? или что -то? В первый раз. Но я не могу получить к нему доступ, так как порт не назначен? < /p>
, и я видел журнал. На случай, если здесь это. < /P>
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
< /code>
Ну ... у кого -нибудь есть решение? > Я могу просто использовать Docker без Compose. и запустите его с < /p>
sudo -S docker run -d -p 8080:8080 --name backend_app backend-backend-app
< /code>
В данном случае он работает так, как намечен намеченное порт и все. < /p>
user@ubuntu:~/.ECM/mdm-backend$ docker exec -it mdm_backend_app netstat -tulpn | grep 8080
tcp 0 0 :::8080 :::* LISTEN 1/java
< /code>
Но это не то, что я хочу. < /p>
Мне нужен < /p>
environment:
- staticHesXmlPath=/mnt/clouhes
volumes:
#- ~/files/logs:/mnt/clouhes
- ~/files/:/files/
- /home/user/clouhes:/mnt/clouhes
< /code>
Это папки синхронизации 2 и загружают файлы XML. < /p>
У кого -нибудь есть хорошее решение здесь? Или я просто должен использовать Docker без составления? < /p>
Хорошо. Почему порт не назначен внутри контейнера, когда я использую Docker Compose.
Мне нужно выяснить проблему здесь и исправить ее. < /P>
Короче говоря, мне нужно назначить порт 8080 для контейнера, когда я использую Docker Compose.
Подробнее здесь: https://stackoverflow.com/questions/794 ... ws-nothing