admin管理员组文章数量:1183186
I have a Java Spring Boot application running inside a Docker container on my laptop (IP: 192.168.0.146:8088), and I can access it without issues from the laptop itself. However, when trying to access it from a different machine on the same network, I get a 502 Bad Gateway error. Firstly I want to connect to auth-service (it works on port 8088)
auth-microservice:
build: ../auth-service
restart: always
ports:
- "8088:8088"
environment:
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL}
SPRING_LIQUIBASE_URL: ${SPRING_LIQUIBASE_URL}
EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE: ${EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE}
networks:
- app-network
depends_on:
- app_database
command: sh -c './wait-for.sh eureka-server:8761 -- java -jar /app.jar'
networks:
app-network:
driver: bridge
docker ps ->
49da3f525838 gateway-auth-microservice "java -jar /opt/app/…" 23 minutes ago Up 16 minutes 0.0.0.0:8088->8088/tcp gateway-auth-microservice-1
I checked:
Port accessibility:
I can ping the laptop from the other machine, and the port 8088 is open (verified using telnet). I’ve ensured the port is correctly exposed in Docker (0.0.0.0:8088->8088/tcp). Spring Boot settings:
I've set server.address=0.0.0.0 to allow Spring Boot to listen on all interfaces. CORS settings:
The CORS configuration has been set to allow all origins in case the request is coming from a browser. Network configuration:
I’m using the default bridge network mode in Docker. The laptop and the other machine are on the same local network.
本文标签:
版权声明:本文标题:Unable to access Java Spring Boot application inside Docker container from another machine - 502 Bad Gateway error - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738296283a2073394.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论