Docker-Compose Hangs on Up when using Port Bindings
I have a docker-compose setup that mostly works, but if I attempt to “up” more than one, or sometimes two, compositions, it will hang until I bring one of the others down. I’m running Docker for windows. I’ve distilled the issue down to the presence of a port mapping. Here are the compose files:
version: '3.9'
services:
db2:
image: mcr.microsoft.com/windows/servercore:ltsc2019
command: ping -t localhost
ports:
- target: 1521
published: 1941
I copy this file and change the published port for each composition. With the port mapping it hangs, without the port mapping it allows me to up as many as I like. I’ve tried many combinations of modifying the default network and using an external network, but nothing helps.
Running these equivalent commands with docker run (in separate cmd instances) has no issue:
docker run -p 1941:1521 mcr.microsoft.com/windows/servercore:ltsc2019 ping -t localhost
docker run -p 1942:1521 mcr.microsoft.com/windows/servercore:ltsc2019 ping -t localhost
docker run -p 1943:1521 mcr.microsoft.com/windows/servercore:ltsc2019 ping -t localhost
docker run -p 1944:1521 mcr.microsoft.com/windows/servercore:ltsc2019 ping -t localhost
I expect that docker-compose should do the same. Up many compositions with no issue.
Here are my docker versions:
Client:
Version: 20.10.10
API version: 1.41
Go version: go1.16.9
Git commit: b485636
Built: Mon Oct 25 07:47:53 2021
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.10
API version: 1.41 (minimum version 1.24)
Go version: go1.16.9
Git commit: e2f740d
Built: Mon Oct 25 07:43:13 2021
OS/Arch: windows/amd64
Experimental: true
Here is docker info:
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.6.3-docker)
compose: Docker Compose (Docker Inc., v2.2.1)
WARNING: Plugin "C:\\Program Files\\Docker\\cli-plugins\\docker-compose_2.1.1.exe" is not valid: plugin candidate "compose_2.1.1" did not match "^[a-z][a-z0-9]*$"
Server:
Containers: 5
Running: 1
Paused: 0
Stopped: 4
Images: 34
Server Version: 20.10.11
Storage Driver: windowsfilter (windows) lcow (linux)
Windows:
LCOW:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics internal l2bridge l2tunnel nat null overlay private transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 19043 (19041.1.amd64fre.vb_release.191206-1406)
Operating System: Windows 10 Pro Version 2009 (OS Build 19043.1348)
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 15.82GiB
Name: CHL1037R
ID: GZAY:G5RE:3TEN:TQBV:NLQ3:PBQV:MHTT:27SX:XYQX:7R3T:EQZN:LKQM
Docker Root Dir: C:\ProgramData\docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
I can’t see any helpful information in the event viewer or panic.log. Here is the output from running up with --verbose:
C:\util\Docker\Projects\ComposeTest3>docker-compose --verbose up
compose.config.config.find: Using configuration files: .\docker-compose.yml
compose.cli.docker_client.get_client: docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
compose.cli.docker_client.get_client: Docker base_url: http+docker://localnpipe
compose.cli.docker_client.get_client: Docker version: Platform={'Name': 'Docker Engine - Community'}, Components=[{'Name': 'Engine', 'Version': '20.10.10', 'Details': {'ApiVersion': '1.41', 'Arch': 'amd64', 'BuildTime': '2021-10-25T07:43:13.000000000+00:00', 'Experimental': 'true', 'GitCommit': 'e2f740d', 'GoVersion': 'go1.16.9', 'KernelVersion': '10.0 19043 (19041.1.amd64fre.vb_release.191206-1406)', 'MinAPIVersion': '1.24', 'Os': 'windows'}}], Version=20.10.10, ApiVersion=1.41, MinAPIVersion=1.24, GitCommit=e2f740d, GoVersion=go1.16.9, Os=windows, Arch=amd64, KernelVersion=10.0 19043 (19041.1.amd64fre.vb_release.191206-1406), Experimental=True, BuildTime=2021-10-25T07:43:13.000000000+00:00
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('composetest3_default')
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {'Attachable': True,
'ConfigFrom': {'Network': ''},
'ConfigOnly': False,
'Containers': {},
'Created': '2021-11-24T15:45:03.1287704-07:00',
'Driver': 'nat',
'EnableIPv6': False,
'IPAM': {'Config': [{'Gateway': '172.24.48.1', 'Subnet': '172.24.48.0/20'}],
'Driver': 'windows',
'Options': None},
...
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
compose.cli.verbose_proxy.proxy_callable: docker info -> {'Architecture': 'x86_64',
'BridgeNfIp6tables': True,
'BridgeNfIptables': True,
'CPUSet': False,
'CPUShares': False,
'CgroupDriver': '',
'ContainerdCommit': {'Expected': '', 'ID': ''},
'Containers': 10,
'ContainersPaused': 0,
'ContainersRunning': 2,
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('composetest3_default')
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {'Attachable': True,
'ConfigFrom': {'Network': ''},
'ConfigOnly': False,
'Containers': {},
'Created': '2021-11-24T15:45:03.1287704-07:00',
'Driver': 'nat',
'EnableIPv6': False,
'IPAM': {'Config': [{'Gateway': '172.24.48.1', 'Subnet': '172.24.48.0/20'}],
'Driver': 'windows',
'Options': None},
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={'label': ['com.docker.compose.project=composetest3', 'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={'label': ['com.docker.compose.project=composetest3', 'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=composetest3', 'com.docker.compose.oneoff=False']})
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('048fd89b5dd7cf7cd03a861784e49ef555871a4b4a3c608f3d13d410d534bec9')
Thanks, Ben
Has anyone tried to replicate this issue? Many members of my team experience it and it's our #1 issue with docker for windows.
So nobody from the community is interested in even attempting to reproduce this issue?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it had not recent activity during the stale period.
This issue has been automatically closed because it had not recent activity during the stale period.
I see the exact same issue. I can replicate every time. I can start 2, not 3. I'm running WSL. Did anyone have anything useful?
I also have the exact problem on Windows Server 2022. First docker-compose is running OK with multiple exposed ports, but the second docker-compose always stuck on starting the container and the Host Network Service (HNS) use 20% of CPU and hangs till I stop the First container.
I'm also seeing this on Windows Server 2022. I thought might be down to the randomisation of ports, i.e. when you don't ask for a specific one and let it randomly pick one, but have since disproven that. Sometimes it works, sometimes it hangs. I cannot even find a way of making it timeout so at least don't have to get onto the box and bounce the services...
It's a major pain, since the whole point to be able to run multiple instances of a container suite!
I'm pretty stunned that this issue was closed over a year ago...
Hi, yes that's right @westy . It amazes me that no one is addressing this issue. Please reopen this issue and resolve it! More information on this issue is described here: https://forums.docker.com/t/docker-compose-does-not-start-container-for-second-environment-on-host-windows-server-2022/137258 and also here: https://github.com/docker/compose/issues/10383