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.

本文标签: