compose icon indicating copy to clipboard operation
compose copied to clipboard

docker-compose V2 fails for port range and replicas>1

Open EParisot opened this issue 2 years ago • 4 comments

Hi, I keep facing this issue with docker compose 2.15.1 with following setting

    ports:
      - "8081-8082:8080"
      - "8444-8445:8443"
      - "9991-9992:9990"
      - "10000-10001:9999"
    deploy:
      replicas: 2

running docker compose up starts the first instance but shows the error message (Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8081 -> 0.0.0.0:0: listen tcp 0.0.0.0:8081: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.), running it a second time make my 2 replicas working as expected (confirmed with docker ps)

CONTAINER ID   IMAGE              COMMAND                  CREATED         STATUS         PORTS
                                                                                  NAMES
74be71e9b594  **********************************   Up 3 minutes   0.0.0.0:8081->8080/tcp, 0.0.0.0:8444->8443/tcp, 0.0.0.0:9991->9990/tcp, 0.0.0.0:10000->9999/tcp   *****************
a07e1560ee5c  **********************************   Up 3 minutes   0.0.0.0:8082->8080/tcp, 0.0.0.0:8445->8443/tcp, 0.0.0.0:9992->9990/tcp, 0.0.0.0:10001->9999/tcp   *****************

Originally posted by @EParisot in https://github.com/docker/compose/issues/8530#issuecomment-1419039923

EParisot avatar Feb 06 '23 13:02 EParisot

possibly a duplicate for https://github.com/docker/compose/issues/7188 (i.e race condition in docker engine)

ndeloof avatar Feb 06 '23 14:02 ndeloof

Hi any news on this issue? There are no good workarounds for us

jbvsmo avatar Sep 25 '23 20:09 jbvsmo