Port mappings are not released

@matteobachetti : Factory reset works but that’s not what I call a solution as it erases all images and force you to re-download dependencies…

Running
rm /var/lib/docker/network/files/local-kv.db; service docker restart;

inside the linux machine seems to clear out this problem.

4 Likes

confirm rm /var/lib/docker/network/files/local-kv.db; service docker restart; works here

Running Docker 1.12.1-stable (build 7135) on Windows 10, and I have a variation on this problem, too.

Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error Unix.Unix_error(Unix.EACCES, “bind”, “”).

Error persists even after removing containers and volumes.

In PowerShell, the command netstat -ano | Select-String "80" shows that TCP 0.0.0.0:80 is LISTENING with Id 4, but Stop-Process 4 returns an Access is Denied error, even when PowerShell is run as Administrator.

Did a Docker reset, downloaded the divio/django-cms-preview image I’ve been trying to explore, and ran it again, which resulted in the same binding error.

upgraded to docker Version 1.12.1 (build: 12133)
The issue cripples various containers with no apparent reason.
Restarting docker, removing containers or images is not working.

While the original problem seems to have gone away for me, my company is now experiencing the same behavior on our Docker Machine infrastructure. The proposed solution above seems to have worked on 1.12.2 and 1.12.3 machines.

docker-machine ssh
sudo rm -f /var/lib/docker/network/files/local-kv.db
exit
docker-machine restart

I’d love to be able to remove this from our troubleshooting docs though.

bump… can this be fixed? seems to be ridiculous we have to wipe all containers to release a port…

still happens! :frowning:

docker version
Client:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 23:26:11 2016
OS/Arch: darwin/amd64

Server:
Version: 1.12.3
API version: 1.24
Go version: go1.6.3
Git commit: 6b644ec
Built: Wed Oct 26 23:26:11 2016
OS/Arch: linux/amd64

Also still having this issue on Docker for Mac (under docker-machine)

The below seems to temporarily fix the issue, however it does appear to come back after any subsequent docker-machine restarts

docker-machine ssh
sudo rm -f /var/lib/docker/network/files/local-kv.db
exit
docker-machine restart

macOS Seirra 10.12

Morgan-Dennings-MBP:Vacasa morgandenning$ docker-machine version
docker-machine version 0.8.2, build e18a919
Morgan-Dennings-MBP:Vacasa morgandenning$ docker version
Client:
Version: 1.12.5
API version: 1.24
Go version: go1.6.4
Git commit: 7392c3b
Built: Fri Dec 16 06:14:34 2016
OS/Arch: darwin/amd64

Server:
Version: 1.12.2
API version: 1.24
Go version: go1.6.3
Git commit: bb80604
Built: Tue Oct 11 17:00:50 2016
OS/Arch: linux/amd64

I run in to this issue and was able to resolve by shutting down a homeberw apache service which was running concurrently. Not sure if that is by design or a conflict with my httpd setup but the two can not run together for me. Given the one vm at a time for Docker for mac this makes sense to me…

thanks very much, running

Running into this on Docker for Mac (version 1.13.1-rc1-beta40 15241). Restarting Docker / or clearing out cache (rm -rf ~/Library/Caches/com.docker.docker) doesn’t help.

docker: Error response from daemon: driver failed programming external connectivity on endpoint nats (5d4be9a93c019ac0edbb2bc4aaecbdb4e4e6ecd7b20098cf16e992ebc089f498): Error starting userland proxy: listen tcp 0.0.0.0:4222: bind: address already in use.

I had to bind (-p$HOST_PORT:4222) to a different host port to workaround this. Note: There was nothing on :4222 port (lsof -i :4222 doesn’t show anything).

1 Like

I’m still noticing the same thing as you on Docker for Mac (Docker version 17.03.0-ce, build 60ccb22). When it gets to this state I have had to restart the Docker engine as mentioned in an earlier post.

Still looking for a better solution to avoid down time on an internal service. Next time I see this I will try your workaround. :slight_smile:

Still broken as for

Docker for mac
Version 17.03.0-ce-mac2 (15654)
Channel: stable
1d7d97bbbd
```

I’m also having this issue

Version 17.03.1-ce-mac5 (16048)
Channel: stable
b18e2a50cc

Having this with Ubuntu 14.04, Docker 17.03.1-ce

Also still seeing this. When I start up a full suite of containers with docker-compose (about 12 containers), I often run into the dreaded userland proxy issue. Sometimes I can run the docker-compose up command again and it’ll bring up the container after all, but other times it errors out again and in that case it’s the port that doesn’t get released.

first error:

Starting dockercomposefiles_lb_1 ... error

ERROR: for dockercomposefiles_lb_1  Cannot start service lb: driver failed programming external connectivity on endpoint dockercomposefiles_lb_1 (f7350b9744f3d4e8f8c9fffc829b328ec195e89110dd39a5585f46d6608d2cf0): Timed out proxy starting the userland proxy

ERROR: for lb  Cannot start service lb: driver failed programming external connectivity on endpoint dockercomposefiles_lb_1 (f7350b9744f3d4e8f8c9fffc829b328ec195e89110dd39a5585f46d6608d2cf0): Timed out proxy starting the userland proxy
    ERROR: Encountered errors while bringing up the project.

Then when I run docker-compose up again:

Starting dockercomposefiles_lb_1 ... error

ERROR: for dockercomposefiles_lb_1  Cannot start service lb: driver failed programming external connectivity on endpoint dockercomposefiles_lb_1 (f89f7702f822d0a06e7529d521fbc28731c388c3033d5b59bb39f6085b9b19cf): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:443:tcp:172.18.0.16:443: file exists

ERROR: for lb  Cannot start service lb: driver failed programming external connectivity on endpoint dockercomposefiles_lb_1 (f89f7702f822d0a06e7529d521fbc28731c388c3033d5b59bb39f6085b9b19cf): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:443:tcp:172.18.0.16:443: file exists
ERROR: Encountered errors while bringing up the project.

Also broken for me. Happend when I experienced a crash on my mac. Restarted and reset docker to factory settings but didn’t seem to help.

Docker version Version 17.03.1-ce-mac12

port is already allocated
ERROR: Encountered errors while bringing up the project.

Error when publishing nginx container on mac.
Docker version 17.09.0-ce, build afdb6d4

docker: Error response from daemon: driver failed programming external connectivity on endpoint wizardly_sinoussi (07e1b8c6aca7cd0ba244e3d8b3fab8d33e46ac76d3e53f479cb34ce9c5bee5cc): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE).

Does someone know how to fix this ? I’m new to docker.

I was getting this issue on Docker for Windows, both ports 5432 and 80. I had a local instance of Postgres blocking 5432 and IIS was blocking port 80. Stopping both of those services fixed the issue for me.