-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port conflict with multiple "host:<port range>:port" services #7188
Comments
I am experiencing a similar issue that may come from the same cause.
The error shown:
I have already taken down every component related to NFS on the Mac itself, and nothing is occupying that port.
Just downgrading to Docker Desktop 2.1.x solves everything. |
Wondering how this would've worked before, as it wouldn't be possible to have two processes listening on the same port 🤔 |
@thaJeztah should I file a separate issue, as it is not directly related to Docker compose?
|
Also when you add scale and run the command multiple times, it will create more containers than the "scale" value. For example when I ran it with --scale=3 for the first time it creates one container successfully and two containers fail with port conflicts. Second time 2 containers success 1 fails, 3rd time 2 success 1 fails. when I execute |
Any news on this? After upgrading docker on mac to > 2.0 my compose script using port ranges on scalable service also fails. It works perfectly on docker < 2.0. |
@MartinLyne Did you find any solutions for this? |
Same problem on MacOS with Docker Desktop v3.1.0 (51484) with the following docker-compose.yml:
First call fails, second call works:
So I tried: |
The error occurs whenever a services which exposes a host port range is scaled, e. g.
Running 3 instances of this services with
results in a port conflict. Running this command three times resolves the problem. I use docker version 19.03.12 and docker-compose 1.29.0 on Windows 10 (WSL 2). |
Still occurs on docker version v20.10.7, docker-compose 1.29.2 on Windows 10 (WSL 2). |
Same issue with latest versions in Win 10 (WSL 2) |
Similar issue on Docker v20.10.7 and docker-compose v2.0.0 on Windows 10 (WSL 2). Compose File version: "3.8" services: app: image: mishroleapp environment: MONGO_URL: "mongodb://mongodb:27017/test" depends_on: - mongodb ports: - "3000-3001:3000" mongodb: image: mongo
[+] Running 2/4 - Network docker_default Created 0.2s - Container docker_mongodb_1 Started 5.4s - Container docker_app_2 Starting 4.9s - Container docker_app_1 Starting 4.9s Error response from daemon: Ports are not available: listen tcp 0.0.0.0:3000: bind: Solo se permite un uso de cada dirección de socket (protocolo/dirección de red/puerto)
NAME COMMAND SERVICE STATUS PORTS docker_app_1 "docker-entrypoint.s…" app running 0.0.0.0:3001->3000/tcp, :::3001->3000/tcp, 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp docker_app_2 "docker-entrypoint.s…" app created docker_mongodb_1 "docker-entrypoint.s…" mongodb running 27017/tcp |
Updates? 😪 |
Same issue pulling down the most recent Confluent platform binaries: docker-compose up -d ERROR: for zookeeper Cannot start service zookeeper: Ports are not available: listen tcp 0.0.0.0:2181: bind: An attempt was made to access a socket in a way forbidden by its access permissions. Issue happens with both Docker Desktop 3.0.0 / 4.2.0 Update Here's a snippet of the yaml with the definitions: `version: '2' broker: |
doesnt work on:having the same issue on Docker Desktop 4.3.2 (72729) win10 2004 works on:rocky linux 8.5
docker-compose:
compose file:
docker command:
|
Still not working: uname -a
# => Darwin my-username 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64
docker --version
# => Docker version 20.10.13, build a224086
docker-compose --version
# => docker-compose version 1.29.2, build 5becea4c
version: '3.7'
services:
solr:
image: solr:latest
ports:
- 8983-8993:8983 scaling fails: docker-compose up --scale solr=5
|
I'm also experiencing this same issue for my microservices project. I can't scale my services due to port conflicts. I have the range 40000 to 41000, and I just have to get lucky to get the three instances of the service running.
|
Still having the same issue: docker-compose.yaml
running But running |
Still having the same issue: version: '3.8'
networks:
app-tier:
driver: bridge
services:
redis:
image: docker.io/bitnami/redis:7.0.5
environment:
- REDIS_REPLICATION_MODE=master
- REDIS_PASSWORD=bitnami
networks:
- app-tier
ports:
- '6379'
redis-slave:
image: docker.io/bitnami/redis:7.0.5
environment:
- REDIS_REPLICATION_MODE=slave
- REDIS_MASTER_HOST=redis
- REDIS_MASTER_PASSWORD=bitnami
- REDIS_PASSWORD=bitnami
ports:
- '6379'
depends_on:
- redis
networks:
- app-tier
redis-sentinel:
image: docker.io/bitnami/redis-sentinel:7.0.5
environment:
- REDIS_MASTER_PASSWORD=bitnami
depends_on:
- redis
- redis-slave
ports:
- '26379-26381:26379'
networks:
- app-tier docker compose up --scale redis-sentinel=3 |
Same issue here on both macOS and linux. Has anyone from Docker org actually commented on this? possibly providing some work around?
and the same on mac:
|
@thaJeztah this seems to be the same race condition issue we discussed on #10067 |
As suggest by @ndeloof, introducing delays may mitigate the problem.
Configure delay seconds based on your container startup. |
@robertoporceddu that's weird you get this fixed this way, as Docker Compose doesn't use |
Still same problem here and
docker-compose up -d
docker --version
docker-compose --version
wsl --version
|
If I create replicas of a container, and use a port range, I still get that same error message: Compose file excerpt: ports:
- target: 3000
published: "3000-3010"
mode: host
deploy:
mode: replicated
replicas: 3
restart_policy:
condition: any
delay: 5s
window: 120s
update_config:
delay: 5s
failure_action: rollback
max_failure_ratio: .5
monitor: 5s
parallelism: 1 Error message:
I would expect this to be a pretty normal use case, is there no way to run replicas on one host without port conflicts? |
I found a setting that works, at least for the abovementioned problem (replicas causing port conflict). Just leave the Works: ports:
- target: 3000 or: ports: "3000-3010" Does Not Work: ports:
- target: 3000
published: "3000-3010" or: ports: "3000-3010:3000-3010" or: ports: "3000:3000-3010" |
This actually worked for me, thank you! All the previous approaches did sadly not. There was one fix I needed to do, which was to specify the protocol, otherwise the communication via node failed: ports:
- target: 3000
protocol: tcp Leaving protocol undefined shouldn't cause any issues (as this, according to documentation, simply allows any protocol), but specifying it was the only way to make it work for me. |
Hi any news on this issue? There are no good workarounds for us |
Hi. Same problem, anything new about this? |
|
I am using version 2.23.0 and the problem persists |
using Docker Desktop 4.26.1 - same problem. |
Hello. This might be related: we experience a I described a simple repro here: [BUG] Regression: array items[0,1] must be unique starting from 2.24.1 #11371
|
@ErjanGavalji thanks for reporting, unrelated to original issue AFAICT, this is a parsing error fixed by compose-spec/compose-go#565. Any reason you use |
@ndeloof, I hope I got your question properly. This is an attempt to provide the simplest repro, hence the service in the secondary.yml empty. In the full scenario we have volumes and env variables declared. We do not override the port or declare other ports, though. |
Sure, was just wondering this was revealing some unknown use-case. But to confirm, if your |
@ndeloof Thanks for the tip, had missed that! |
Description of the issue
If a compose file defines multiple services that share an overlapping port range, a port conflict occurs when
docker-compose up
is executed. This behavior started to happen for me when upgrading to Docker Desktop 2.2.0 (Stable) for Mac. The version I was previously running (I believe 2.1.5) was able to select distinct ports for the two services without conflicting. Here is a POC Docker Compose file:Context information (for bug reports)
Output of
docker-compose version
Output of
docker version
Output of
docker-compose config
(Make sure to add the relevant
-f
and other flags)Steps to reproduce the issue
docker-compose up
Observed result
Services fail to start and a port conflict error occurs
Expected result
Services start up. An available port within the overlapping range is selected for each service.
Stacktrace / full error message
Additional information
I uploaded diagnostic information with the ID
37C41A27-71E7-4431-AFBE-5DA0EEC74A3C/20200126225028
The text was updated successfully, but these errors were encountered: