Home > Software engineering >  Docker compose: can not connect to external port
Docker compose: can not connect to external port

Time:10-18

How looks my docker compose:

version: "3.3"
services:
  app-1:
    build: docker/.
    ports:
      - 8080:8080
    volumes:
      - .:/app-1

  app-2:
    build: docker/.
    ports:
      - 8080:8090
    volumes:
      - .:/app-2

My problem: i can not connect to external docker port.

When i have ports '8090:8090' for app-2 i connect successfully to my application.

But when i am using '8080:8090' i can not connect to it.

Could you give me an advice where could be reason?

The app-1 have server.port=8080

The app-2 have server.port=8090

CodePudding user response:

you are trying to map the same port 8080 to 2 different services, the operation system won't allow it, a listening port can have only one service.

CodePudding user response:

This is why the same ports are specified for both of your apps, you can't run 2 apps on same port, so they must be different f.e.

version: "3.3"
services:
  app-1:
    build: docker/.
    ports:
      - 8080:8080
    volumes:
      - .:/app-1

  app-2:
    build: docker/.
    ports:
      - 8081:8090
    volumes:
      - .:/app-2

Docs

  • Related