Port mappings are not released

I can confirm that this bug happened to me. But why don’t you try the following:

$ docker ps -a

In the output I’ve had a dead/zmobie/alive/whatever process that wanted to take the port 80 for some reasons:

28e40ca16e2a        node:0.12.9         "node node_modules/.b"   8 weeks ago         Exited (137) 5 weeks ago          0.0.0.0:80->80/tcp   ambmathjax_main_1

I did the usual magic kill them all command to release it:

$ docker rm -fv $(docker ps -aq)

It worked fine after then.

You could just do $ docker rm 28e40ca16e2a instead, but I felt like killing them all instead.

Has this got better in the latest beta? I think there were some fixes here but not sure, if not I will raise an issue, especially if you can provide a means to reproduce.

Still reproducible in beta10, same as @taiidani originally reported for beta9.

Seeing this EADDRINUSE error pretty much every time I stop / start my container as well. Never saw that error with the docker toolbox before. This seems to be the most annoying issue for me at the moment, really hoping it gets fixed quickly.

I can confirm this is still occurring. Tested with nginx (port 80) using docker-compose.

Manually stopping and removing the containers did not resolve the issue.

Docker for Mac: 1.11.1-beta10 (build: 6662)
OS X: El Capitain

I just ran into this today as well.

Docker for Mac: 1.11.1-beta10 (build: 6662)
OS X: El Capitain

To add to @pierce in my env I’m noticing that manually stopping and removing the containers did not resolve the issue either, but I think it’s because the container I was trying to start when i received the error got in a “Created” state and had to be removed as well before the port was released and I could docker run again.

Here’s some console output from when I was diagnosing:

`Juns-MacBook-Pro:mml-ams-server jun$ docker run -d -p 80:80 -p 443:443 -p 1111:1111 -p 1935:1935 e2c35cafd4dd
8d6c57b24638287a23a9067af0b49c1ff6c3f869e9e6dd1bb588bf9e9c2e3c7d

Juns-MacBook-Pro:mml-ams-server jun$ docker stop 8d6c57b24638287a23a9067af0b49c1ff6c3f869e9e6dd1bb588bf9e9c2e3c7d
8d6c57b24638287a23a9067af0b49c1ff6c3f869e9e6dd1bb588bf9e9c2e3c7d

Juns-MacBook-Pro:mml-ams-server jun$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8d6c57b24638 e2c35cafd4dd “/usr/bin/supervisord” 35 seconds ago Exited (0) 5 seconds ago jovial_fermat
837f6a5f5c1b 3216e2f0fda6 “/bin/sh -c /bin/bash” About an hour ago Exited (0) 58 minutes ago determined_sinoussi
8bfad76cfcc8 8900a317fc9a “/bin/sh -c 'chmod +x” 7 days ago Exited (1) 7 days ago determined_lovelace

Juns-MacBook-Pro:mml-ams-server jun$ docker run -d -p 80:80 -p 443:443 -p 1111:1111 -p 1935:1935 e2c35cafd4dd
e089a12f1c27084c170a48bc730edf7c00176ed54fc2c26d58b3a9a5d816e016
docker: Error response from daemon: driver failed programming external connectivity on endpoint ecstatic_archimedes (8f9960951348631c5009b7f8d9e5c5c0aa60a2d0b3f1e271362e0bd4c411c2bd): Error starting userland proxy: Failed to bind: EADDRINUSE.

Juns-MacBook-Pro:mml-ams-server jun$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e089a12f1c27 e2c35cafd4dd “/usr/bin/supervisord” 22 seconds ago Created ecstatic_archimedes
8d6c57b24638 e2c35cafd4dd “/usr/bin/supervisord” About a minute ago Exited (0) 31 seconds ago jovial_fermat
837f6a5f5c1b 3216e2f0fda6 “/bin/sh -c /bin/bash” About an hour ago Exited (0) 58 minutes ago determined_sinoussi
8bfad76cfcc8 8900a317fc9a “/bin/sh -c 'chmod +x” 7 days ago Exited (1) 7 days ago determined_lovelace

Juns-MacBook-Pro:mml-ams-server jun$ docker rm e089a12f1c27
e089a12f1c27

Juns-MacBook-Pro:mml-ams-server jun$ docker rm 8d6c57b24638
8d6c57b24638

Juns-MacBook-Pro:mml-ams-server jun$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
837f6a5f5c1b 3216e2f0fda6 “/bin/sh -c /bin/bash” About an hour ago Exited (0) About an hour ago determined_sinoussi
8bfad76cfcc8 8900a317fc9a “/bin/sh -c 'chmod +x” 7 days ago Exited (1) 7 days ago determined_lovelace

Juns-MacBook-Pro:mml-ams-server jun$ docker run -d -p 80:80 -p 443:443 -p 1111:1111 -p 1935:1935 e2c35cafd4dd
5844c74eccf5e05f686e13b60fc87048e73a6243cfef2e365a4dd7a6b73b8c66

Juns-MacBook-Pro:mml-ams-server jun$ docker stop 5844c74eccf5e05f686e13b60fc87048e73a6243cfef2e365a4dd7a6b73b8c66
5844c74eccf5e05f686e13b60fc87048e73a6243cfef2e365a4dd7a6b73b8c66

Juns-MacBook-Pro:mml-ams-server jun$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5844c74eccf5 e2c35cafd4dd “/usr/bin/supervisord” 22 seconds ago Exited (0) 3 seconds ago determined_pasteur
837f6a5f5c1b 3216e2f0fda6 “/bin/sh -c /bin/bash” About an hour ago Exited (0) About an hour ago determined_sinoussi
8bfad76cfcc8 8900a317fc9a “/bin/sh -c 'chmod +x” 7 days ago Exited (1) 7 days ago determined_lovelace`

Having the same issue… How does one get the port released (or just things “clean”) when this occurs?

docker rm -fv $(docker ps -aq) is not enough.

Stopping the docker for mac daemon (from the OSX taskbar) and restarting it
works fine but is not the fastest solution :frowning:

2 Likes

Same issue here with the nginx image, and the various workarounds posted here do not solve the problem,
so I had to give up and go back to bootdocker which is unfortunate.

Version 1.11.1-beta10 (build: 6662)
El Capitan

ERROR: for nginx_instance driver failed programming external connectivity on endpoint dockerbeta_nginx_instance_1 (fb44ceb9663bc09019c1ea46d87b76c2eb50834dace7f8eb78c71abfbf057bbf): Error starting userland proxy: Failed to bind: EADDRINUSE

If the message is from Docker could the IP address that’s in use be added to the error message? Might give some kind of clue.
I changed the nginx image to an nginx debug image, but of course that made no difference.

For what it’s worth I’m still using links instead of networking.
However have tried with networking, but the error message is exactly the same.

Having the same problem. When you just recreate a container in a docker-compose setting it’s very annoying. I reverted back to using a vagrant box. Hope this is solved soon…

My guess is that the error message in my case was simply telling the bald truth (see my first message above)

The point, I suppose, is this:

bootdocker created a separate machine for docker on 192.168.99.100, whereas the docker beta uses our local, actual machine.
In my case I was still using my config as if I was still using bootdocker.

So, the ports bit in my .yml file is:
ports:
- “80:80”
- “443:443”

But my port 80 really is already occupied on my machine - by apache, and EADDRINUSE is entirely appropriate.

I thought of assigning different ports for docker like 8000 and 444, but opening ports on mac these days is too complicated.
So I shutdown Apache, which was squatting on 80 and 443, and restarted docker-compose using the original ports.

In my case this has solved the problem and no amount of stopping and starting has made it appear again.

1 Like

Your first experience wasn’t the actual bug, it was a configuration error. Run docker-compose restart [service] on that service a few times to experience the bug in all of its glory.

Add me to the list of people suffering from this bug. I’m reverting to Docker Toolbox until it’s fixed.

I guess it’s unrelated as it sounds like port 80 and 443 are the problem, but note that you can’t bind port 2375 & 62374, see:

$ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
moby:~# netstat -tlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 :::62374                :::*                    LISTEN      1490/diagnostics-se
tcp        0      0 :::2375                 :::*                    LISTEN      1249/docker```
crazy sheep uploaded this image to

This should be fixed in Beta 11. Please let me know if the issue persists!

Confirmed! My test steps appear to all be working now, even for privileged ports.

I had some other application listening to the same port I was trying to map to container. Stopping that application solved the problem.

Probably fixed as of beta 11 as said above. Works just fine for me in beta 12 (missed out on beta 11).

I am still having this issue. I am using Docker for Windows Beta 16 installed yesterday. Need some help!!!

S C:\Users\monu\Documents\Visual Studio 2015\Projects\WebApplication3\src\WebApplication3> .\DockerTask.ps1 -Run -Environment Release
ERBOSE: Setting: $env:CLRDBG_VERSION = "VS2015U2"
ERBOSE: Setting: $env:REMOTE_DEBUGGING = 0
ERBOSE: Executing: docker-compose -f ‘C:\Users\monu\Documents\Visual Studio
015\Projects\WebApplication3\src\WebApplication3\bin\Docker\Release\app\docker-compose.yml’ -p webapplication3 up -d
tarting webapplication3_webapplication3_1

RROR: for webapplication3 driver failed programming external connectivity on endpoint webapplication3_webapplication3_1 (a7af435eb06b1435969078dac7c5c99216
9a60e3d5b39be0ee254fe3b53db3d): Bind for 0.0.0.0:80 failed: port is already allocated
RROR: Encountered errors while bringing up the project.
un : Failed to start the container(s)
t C:\Users\monu\Documents\Visual Studio 2015\Projects\WebApplication3\src\WebApplication3\DockerTask.ps1:491 char:5
Run
~~~

  • CategoryInfo : NotSpecified: (:slight_smile: [Write-Error], WriteErrorException
  • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Run

Works in beta 12 if you do not map container to a port in use. My port 80 is being used by Apache, so if I map it to 8888, it works. docker run -d -p 8888:80 --name test_web_server nginx

1 Like