compose: "driver failed programming external connectivity on endpoint" (1.7.0-rc1)

I’m pretty sure this was working on docker-compose 1.7.0-rc1 before I installed the latest Docker for Mac beta, which upgraded to docker 1.11.0-rc3. I’m trying to get the socat service to run on port 172.17.0.1:8123, so that it’s available to docker builds. My real yml uses an environment variable for the IP address, but it happens even when hardcoded.

ERROR: for socat_httpcache  driver failed programming external connectivity on endpoint test_socat_httpcache_1 (5d973ed559d63a5561b715248f797a336915a44960b5e32e622ac8349b16e5d2): Error starting userland proxy: failed to bind port: Unix.Unix_error(Unix.EADDRNOTAVAIL, "bind", "")
version: '2'
services:
  httpcache:
    restart: always
    image: clue/polipo
    command: proxyAddress=0.0.0.0 allowedClients=0.0.0.0/0 disableIndexing=false disableServersList=false
    mem_limit: 500m
    memswap_limit: 500m
    volumes:
      - /var/cache/polipo

  socat_httpcache:
    restart: always
    hostname: POLIPO1
    image: bobrik/socat
    mem_limit: 50m
    command: TCP-LISTEN:8123,fork,reuseaddr TCP:httpcache:8123
    depends_on:
      - httpcache
    ports:
      - "172.17.0.1:8123:8123"

verbose.txt

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 123
  • Comments: 305 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Please stop sending +1, as it spams all subscriber inboxes. Either use the emoticons (smiley on the right of each comment) or at least give your full setup, version numbers and so on. Thx

on osx the built-in apache web server may be running on ports 80/443. To check: ps -ef | grep httpd

To turn it off: sudo apachectl stop

@jamshid Can you post the o/p of sudo netstat -nlp | grep 8123. Thanks.

Sometimes docker-compose fails to start the desired container and leaves the port occupied with a process listening… so try listing all the (listening) ports using

lsof -nP +c 15 | grep LISTEN

# outputs
Dropbox             384  IPv4 0x82c      TCP 127.0.0.1:17600 (LISTEN)
com.docker.slirp   6218  IPv4 0x82c      TCP *:5432 (LISTEN) <<<MOSTLY THE PROBLEM
Python             6268  IPv4 0x82c      TCP 127.0.0.1:51617 (LISTEN)

# then kill the com.docker.slirp process id if it's the one causing the problem
kill -9 6218

UPDATE: I was also able to reproduce this issue (multiple times)… start a service locally that is listening to port XXX and start a container that exposes the same XXX port… it’ll fail to run docker-compose up and the com.docker.slirp process will not be killed causing the problem to persist till the com.docker.slirp process killed manually ( I even added an alias to do so alias portfix='pkill com.docker.slirp')

It seems there are many flavours of this issue. Here’s mine:

Docker for Windows on Windows 10.

It seems the latest Windows 10 update (Fall Creators Update, 2017) has a new “feature”. When you shutdown it remembers what’s running so it can start them back up for you when you restart.

This wrecks havoc with Docker for Windows (and erased several hours of my time before I made the connection). Got the dreaded “driver failed programming external connectivity on endpoint” when trying to re-up my docker-compose.

Turns out, in this case, simply restarting Docker solves it. Didn’t find that right away, because I restarted the computer. Thinking this would also restart Docker. No - it reconstituted Docker in a bad state.

There appears to be no way to turn off this new feature of Win10. https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_perf-insiderplat_pc/programs-autostart-after-boot-in-windows-10-fall/09dd8d3e-7b36-45d1-9181-6587dd5d53ab

Instead, to shutdown “properly” we are forced to run this from command prompt: shutdown /s /t 0 or restart Docker when I forget to do this.

This solved my issue on windows :

  • docker-compose down
  • Close docker desktop.
  • Kill docker service image
  • Start docker, a popup will ask you to activate docker service via net.exe, accept
  • docker-compose up

@tsantos84 Docker will be running inside a VM when you’re using Docker for Mac.

Try the following (I haven’t tested this though):

  • docker rm -f $(docker ps -aq) (will remove all of your containers)
  • docker network rm $(docker network ls -q) (will remove all of your networks)
  • docker run --rm -v /var/lib/docker/network/files:/network busybox rm /network/local-kv.db

Then restart Docker for Mac and you should be good to go 👍

Hello, I had the same problem with Docker version 1.11.1 on Mac OSX. ERROR: for nginx driver failed programming external connectivity on endpoint managercentralapp_nginx_1 (e11d19ee8f486a2e12c9c87802dca7ea5f541f026645f69e338e94732ac1eb56): Error starting userland proxy: Failed to bind: EADDRINUSE

Just Restart Docker. It worked for me.

same thing happening to me.

Found this thread, and none of the above helped me.

I am running Ubuntu and I had to use:

sudo service docker restart

I tried prune and all the other commands and docker was sure it had nothing running, but after restarting the service, it all started working again.

THANK YOU! HOLY FK, I SPENT A WHOLE DAY TRYING TO FIX THIS.
THE YEAR IS 2020, THAT’S 4 YEARS AND THIS PROBLEM STILL EXISTS. WTF

3 years and this bug is still alive and well…

+1 on mac 😦

+1 on Mac

+1 same problem on the mac with docker for mac

I am getting the same issue when restarting using docker-compose up. In my case it’s an nginx proxy service that fails to start. Must be related to the Docker for Mac beta. It started after I installed the beta and hasn’t happened after switching back over to Virtualbox.

docker-compose version 1.7.0, build 0d7bf73 Docker version 1.11.0, build 4dc5990

for me a manual restart of docker made it work

Using docker for mac, in my case removing all containers and killing docker process occupying the ports were not enough to fix the issue. I had to remove the networks associated with those ports as well.

stop & remove docker containers: docker stop $(docker ps -a -q); docker rm $(docker ps -a -q); docker volume rm $(docker volume ls -qf dangling=true)

remove problematic networks: docker network rm(docker network ls -q)

find out which process occupies the port lsof -nP | grep LISTEN

examine the output of last command and kill the process occupying the port (see @mad-raz 's post on how to do that). Following these steps fixed the issue for me.

Found this thread, and none of the above helped me.

I am running Ubuntu and I had to use:

sudo service docker restart

I tried prune and all the other commands and docker was sure it had nothing running, but after restarting the service, it all started working again.

Found solution for people with same error as I shown above. I was previously using Docker Toolbox, but I did not delete Virtualbox. It was using my ports so I can not start. After complete removing VirtualBox, docker-compose worked awesome.

@aanand @dnephin please, add to Getting Started a warning like explained above.

My mac says -p requires an argument, so I think this is what you want:

$ sudo netstat -nl -p tcp  | grep 8123
(nothing)
$ sudo netstat -nl -p tcp  | head    # to confirm mac output is what you expect
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)    
tcp4       0      0  192.168.2.4.52918      216.58.194.34.80       ESTABLISHED
tcp4       0      0  192.168.2.4.52917      23.199.236.147.80      ESTABLISHED
tcp4       0      0  192.168.2.4.52916      192.229.163.25.443     ESTABLISHED
tcp4       0      0  192.168.2.4.52915      192.229.163.175.80     ESTABLISHED
...
$ docker ps -a | grep 8123
7baf5b2ec0eb        clue/polipo               "polipo proxyAddress="   26 minutes ago      Up 12 minutes                  8123/tcp            test_httpcache_1
3fea15e3d5b4        clue/polipo               "polipo proxyAddress="   33 minutes ago      Up 19 minutes                  8123/tcp            buildenv_httpcache_1

follow madjam002 's method got this solved.

  1. docker rm -f all containers.
  2. docker network rm network interfaces.
  3. sudo rm /var/lib/docker/network/files/local-kv.db and restart, it worked. thanks buddies.

I had a similar problem Docker for Mac running nginx container, my port 80 was being used by apache (native). I used telnet and netstat to see the running service.

If anyone using Docker Desktop Follow Below steps : (Avoid Restarting Docker Desktop)

  • Quit Docker Desktop
  • Start Docker Desktop again
  • It will work fine

restart docker work for me. on windows 10

Same problem here. FIXED WHEN I restarted Docker, and the ports were released - sorted

To solve the following error in Windows Restart Docker (from tray menu or selecting the ‘Restart Docker…’ option in Settings/Reset)

Cannot start service YOUR_SERVICE: driver failed programming external connectivity on endpoint

Restarting docker works

I figure out what the problem is about, the container (consul) causing the issue has this binding port 172.17.0.1:53:8600/udp. I replaced it with 53:8600/udp and it’s working now. I didn’t understand yet why the first binding doesn’t work. BTW, How can I know the bridge ip address?

this is what finally worked for me on my mac: sudo /usr/sbin/apachectl stop you can then tell that httpd is not there by running ps -ef | grep httpd

I had this happening after a move to Docker for Mac, but after stopping and removing All containers after the move, restarting docker, recreating container etc etc. It was fixed.

I had this again today after an update of Docker for Mac , but repeating the above scenario fixed. I assume the port (and “other” things) I’m assigning to particular containers is not being released until completely cleaned up.

eg:

ERROR: for nginx driver failed programming external connectivity on endpoint dev_nginx (4c340c55f7402c7b265803ea64541ebdf8613f4b43dfa816001d27bdc4f513b3): Error iptables FORWARD: Another app is currently holding the xtables lock; waiting (1s) for it to exit... ERROR: Encountered errors while bringing up the project.

Restart Docker…just that

I had the same error message and I restarted Docker on Windows. It did the trick.

Restart Docker works for me. (Docker for Windows, Docker version 18.06.1-ce, build e68fc7a)

Simply restarting docker fixes this issue for me.

I’m seeing this sporadically. Retrying the command after a minute usually “fixes” the problem. This is after moving to Docker for Mac yesterday.

$ docker version
Client:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   906eacd
 Built:        Fri Jun 17 20:35:33 2016
 OS/Arch:      darwin/amd64
 Experimental: true

Server:
 Version:      1.12.0-rc2
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   a7119de
 Built:        Fri Jun 17 22:09:20 2016
 OS/Arch:      linux/amd64
 Experimental: true

Restart docker works for me

+1 Same error on mac

Full error:

Error response from daemon: driver failed programming external connectivity on endpoint xxx_xxx_1 (xxx): Bind for 0.0.0.0:2224 failed: port is already allocated

netstat:

tcp6       0      0 :::2224                 :::*                    LISTEN      9083/docker-proxy

I encouner the same error when I try to start my stack using docker-compose. All the containers start correctly except one (consul). I’m getting this error

ERROR: for consul driver failed programming external connectivity on endpoint devas_consul_1 (6ceba32c51cb70b354f 2f4b68d173ca97a65d6a0bfd308d3137e2a7069abd1b6): Error starting userland proxy: Failed to bind: EADDRNOTAVAIL

I’m sure it has something to do with my docker version beta for mac.

docker-compose -v docker-compose version 1.7.0, build 0d7bf73

I’m using the last docker beta version for mac

` docker version Client: Version: 1.11.1 API version: 1.23 Go version: go1.5.4 Git commit: 5604cbe Built: Wed Apr 27 00:34:20 2016 OS/Arch: darwin/amd64

Server: Version: 1.11.1 API version: 1.23 Go version: go1.5.4 Git commit: 8b63c77 Built: Fri Apr 29 14:13:26 2016 OS/Arch: linux/amd64 `

I need to restart docker every day… would really love to get this fixed!

Just Restart Docker. It worked for me.

This worked for me as well.

If you have MAC, try to stop server. I have apache. sudo /usr/sbin/apachectl stop

Following the above message, I get Error starting userland proxy: Failed to bind: EADDRINUSE. Confused as to where the conflict is where none existed before

restart docker can resolve everything, that because restart docker would clean up all the running container.

I check my docker compose.yml file again, and delete the container which located inside the docker-compose.yml file either, and no need to restart the docker.

enjoy.

it help me by reset Docker.

Restarting docker (via “Restart” command or manually quitting and re-launching) did NOT work for me.

I’ve had pretty same issue, with Docker for Mac, running postgresql container. So, for me it was caused by postgres running on same port on host system as port specified in my compose config file. Pretty obvious thing, but could be helpful for someone I guess. Thanks for cool tool. 👍

I was also facing the same problem but after a long time a meet with the perfect solution

  1. type docker container ls -a (check the container which is using that port number )
  2. docker container rm -f <container ID> (Deallocate the port by removing that container)
  3. Assing your new container with your port number

I am getting this issue pretty regularly(on windows ) and restarting Docker solves the problem.

my solution was -> Reset Docker to factory defaults

same issue Windows 10

On MAC stop internal apache

sudo apachectl stop

If you’re on a Mac and your docker web server won’t start, it might be File Sharing - Apple uses the built-in Apache for that. Either…

sudo apachectl stop

or better yet, turn off file sharing.

@yedincisenol yes, but having to restart every day is a bit annoying

Sorry to be that guy, but at my machine, rebooting the computer was the solution. Docker restart did not help.

For windows users: Disable “fast startup” in your power settings and it works! https://stackoverflow.com/a/47818614

The last Windows 10 update (Fall Creators Update, 2017) has a new “feature”. It automatically starts any applications that were running when you last shutdown. This reconstitutes Docker for Windows in a bad state. That made it appear those ports were in use by something else - it was the ghost of itself. This explained why those ports were still in use even though I stopped/started my containers and even reboot!

Ubuntu 18.04, restarting docker solve the problem

To add to Ray-Eldath’s comment: I was confused because restarting my computer twice didn’t work (same version: 18.06.1-ce for Windows), and surely restarting your computer is enough to count as restarting Docker too, right? So I guess restarting didn’t fix it, right? Well, no, lol. I actually go to Docker and click “Restart” and now it works.

EDIT: Oh, interesting, now I know why this happened (probably). Restarting my computer actually created this problem I think. Check this out:

https://stackoverflow.com/questions/40668908/running-docker-for-windows-error-when-exposing-ports

Relevant quote:

The last Windows 10 update (Fall Creators Update, 2017) has a new “feature”. It automatically starts any applications that were running when you last shutdown.

This reconstitutes Docker for Windows in a bad state. That made it appear those ports were in use by something else - it was the ghost of itself. This explained why those ports were still in use even though I stopped/started my containers and even reboot!

Given that, I’m still suspect of the 18.06.1-ce Windows update, since this wasn’t a problem for me until I updated to that.

Encountered the problem on windows. Fails on any service any port, restarting docker fixed it.

@tsantos84 Docker will be running inside a VM when you’re using Docker for Mac.

Try the following (I haven’t tested this though):

* `docker rm -f $(docker ps -aq)` (will remove all of your containers)

* `docker network rm $(docker network ls -q)` (will remove all of your networks)

* `docker run --rm -v /var/lib/docker/network/files:/network busybox rm /network/local-kv.db`

Then restart Docker for Mac and you should be good to go +1

Thank you! It helped me to quickly solve the problem.

Tried the above without success. I got it working by wiping my entire docker cache via running:

docker ps -aq | xargs docker rm -f && \ docker images -q | xargs docker rmi -f && \ docker volume list -q | xargs docker volume rm -f

First, upgrade windows 10 to 1809. Then, turn off “Start Docker desktop when you log in” in the docker setting. Finally, start the docker manually (you don’t have to restart). The problem has gone and it is working well in my computer.

I was also facing the same Problem. I resolved It by restarting the docker. Guys, I see that some time the virtual machine may be occupied with the same ports what you are running now. So, by restarting the docker you can resolve this problem.

Was facing this issue right now on linux. systemctl restart docker fixed it for me.

Well, I’m using docker engine 1.11.2 in centos7 in a Continuous Build/Integration flow to automate tests and as far as I can tell, eventually this error pops up even though no container is running (while re-deploying a specific version of the whole service stack). Also it seems related to the fact that sometimes docker engine gets an error on trying to cleanup after the removal of running containers, and some iptables rules might be kept allocating network ports for some reason, maybe related to https://github.com/docker/docker/issues/23371#issuecomment-229982105 - but I’m still not sure about that.

Just had encountered the same issue complaining about a Postgres container. Curiously, exiting Docker for Mac (desktop) did not solve the trick, I had to actually select Restart from the menu and that fixed the issue.

In fedora 27 I can work around this issue by disabling my firewall and restarting docker.

systemctl stop firewalld systemctl restart docker

@mad-raz Thanks a lot for the solution. I spent hours figuring it out and your answer worked

Sometimes docker-compose fails to start the desired container and leaves the port occupied with a process listening… so try listing all the (listening) ports using lsof -nP +c 15 | grep LISTEN outputs Dropbox 384 IPv4 0x82c TCP 127.0.0.1:17600 (LISTEN) com.docker.slirp 6218 IPv4 0x82c TCP *:5432 (LISTEN) <<<MOSTLY THE PROBLEM Python 6268 IPv4 0x82c TCP 127.0.0.1:51617 (LISTEN) then kill the com.docker.slirp process id if it’s the one causing the problem kill -9 6218

+1 on mac. I tried delete all containers and restart Docker. But It happens again…

one of the causes of this issue, is miss configuring docker-compose.yml if the port is not used outside the containers it should be expose:d instead of ports:ed as using ports exposes the port both to the other service containers and to the host machine… while expose only exposes the port to the other service containers (not interfering with the host port mappings)…

I got it by doing the command sudo systemctl stop httpd or sudo /etc/init.d/apache2 stop

Restart Docker…just that

That’s a great workaround, but restarting indicates a bug and this issue shouldn’t be closed.

stop your docker daemon and start as an admin.

Same problem here @namerci. Need to manually reboot docker after windows are fully booted.

just do it;

sudo apachectl stop

Same issue on Windows 10. Solved by just restarting Docker (reboot of computer didn’t work).

Or, you can connect to the xhyve VM, by:

screen -AmdS docker ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty screen -S docker -p 0 -X stuff screen -r docker rm -f /var/lib/docker/network/files/local-kv.db screen -S docker -X quit

So I managed to fix my issue. Ideally I didn’t want to uninstall Docker as I want to keep all my images, I have quite a few downloaded! Instead, I deleted all my custom networks, removed all my containers and then deleted docker/network/files/local-kv.db and restarted my machine.

It appears that something internally in Docker was broken in this file and persisted, and there was no way to clear it or fix it. This is probably because I started on version 1.11, then went through all the 1.12 release candidates and am now on 1.12, so maybe something along the upgrade path broke it.

Now it seems to be working fine 😄 I have the old local-kb.db file saved if anyone from the Docker team would like to take a look at it if it would be useful. To recap, the problem was the daemon listening on port 80 and 443 even if there were no containers listening on those ports.

This solved my issue on windows :

  • docker-compose down
  • Close docker desktop.
  • Kill docker service image
  • Start docker, a popup will ask you to activate docker service via net.exe, accept
  • docker-compose up

the solution above works for me, thanks.

when docker is running, I got this below. when docker restarted, I still got this below. when docker service killed and restarted, port occupacy gone, docker works again.

**netstat -aon|findstr "5601"**
  TCP    0.0.0.0:5601           0.0.0.0:0              LISTENING       9512
  TCP    192.168.6.202:55601    203.208.41.75:443      TIME_WAIT       0
  TCP    [::]:5601              [::]:0                 LISTENING       9512

**tasklist|findstr 9512**
com.docker.backend.exe        9512 Services                   0     10,916 K

Having same issues on Oracle Linux. Restarting Docker service helped.

I cannot start any container after windows and docker is fully booted. No waiting fixes that. Restarting Docker from Docker for Win status bar icon solves it.

100% of the time Docker doesn’t work after boot/reboot and I have to restart the docker daemon in 100% of the cases.

EDIT: yes, @IGZmanuelMartinVivaldi , this works, but I have to do it every restart of the host. Is this an issue with compose, or with Docker daemon in general?

The same issue on Windows 10. Error response from daemon: driver failed programming external connectivity on endpoint after attempting to restart a container.

Unfortunately none of all the suggestions worked for me. Docker for Mac Edge 18 something. High Sierra.

Only thing that did work was to wait until Docker started after system reboot and then run $ docker-compose up -d --force-recreate manually. Super sad.

In the end I downgraded back to Docker for Mac Stable 17 something and everything works fine again.

@biscuit314 Your suggestion of restarting the docker service worked for me, bit of a problem if Windows isn’t restoring it well or Docker can’t handle how Windows does this.

I had this problem on Windows 10 Pro and I stopped IIS service, then works!

I ended up resetting Docker (and therefore deleting all containers), and that worked again, all ports being released 😕

I’m having the problem with running postgres. I verified that postgres is not running on my host machine with brew services stop postgres. I ran lsof -i :5432 and got the following output:

image

Is docker running postgres for something internal? When I killed the process with SIGINT the docker status bar icon started rolling and it restarted the service. The only way I could get it to work was to change the host port in my docker-compose file.

A workaround by uninstalling docker from the top bar menu (Docker icon > Preferences > Uninstall) and reinstall it 😦

Had same kind of error Error starting userland proxy: write /port/tcp:0.0.0.0:80:tcp:172.17.0.5:80/ctl: errno 526

It was nginx for me. I had to kill the nginx to get around it sudo nginx -s stop

Yes, it is worked for me. I have OS X without activated apache, but few days a got i used this website: https://coolestguidesontheplanet.com/upgrade-php-on-osx/ for update PHP.

After this script

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

recommended for php updating apache was activated and i got surprise with my containers.

When we want “update php” we aren’t want “activate apache”, but website above have first position in the google 😦

Happy dockering!

How does one “release” the port that is in use so that compose can bring up the container again? First time it happened, I waited for a minute or so and it worked on second attempt. Second time, its been about an hour. Docker compose kill, down, rm --all, etc. and something still has a hold of it.

I had the same issue which was caused by my local php8 instance (local apache2 server took over the address) sudo systemctl stop apache2.service Solved it.

I got it by doing the command sudo systemctl stop httpd or sudo /etc/init.d/apache2 stop

same here. Reinstalled PHP on my Ubuntu 20.04 and had a simple test running. Seems like apache runs per default on port 80:

# $ sudo netstat -nlp | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      848/apache2         

just read through this thread, and what seems to be the best answer in 2021 is to restart docker service (sv restart docker, systemctl restart docker, etc …) That indeed makes it work again, but why this is happening is unclear still from this thread

@tsantos84 Docker will be running inside a VM when you’re using Docker for Mac. Try the following (I haven’t tested this though):

* `docker rm -f $(docker ps -aq)` (will remove all of your containers)

* `docker network rm $(docker network ls -q)` (will remove all of your networks)

* `docker run --rm -v /var/lib/docker/network/files:/network busybox rm /network/local-kv.db`

Then restart Docker for Mac and you should be good to go +1

Thank you! It helped me to quickly solve the problem.

Hi @fede-r1c0, I don’t know why you mentioned me and probably you wanted to mark another user. Anyway, I’m happy you solve your problem. 👍

Stopping the docker service in task manager solved my problem on W10

for windows problem easily can solve: just restart your docker and try to run again the server. image

sudo apachectl stop this worked for me as it seemed that apache was running on Mac

Clicking on the Docker Desktop icon on tray and select Restart… worked for me on Windows 10!

Restarting docker is worked for me only first time. After that whenever i hit docker run command it gives me same error. It is not fixed permanently.

What i am trying to achieve:

I am just trying to setup LEMP (nginx, php-fpm, MySQL) environment on my centos 7 machine.

Commands:

Restarted docker

service docker restart

Create bridge network

docker network create -d bridge LEMP

Run php-fpm container

docker run --name php-fpm -v /home/ashish/work/docker/php:/app -p "9000:9000" --network LEMP --rm -d php:7-fpm

On first run command after, It works with following output:

b003815c0ee2fba05aa24b0965871b55ce717fcd56557066acd448519b59498b

iptables -L

target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere             state NEW
ACCEPT     all  --  anywhere             anywhere             state NEW
ACCEPT     icmp --  anywhere             anywhere             state NEW
ACCEPT     icmp --  anywhere             anywhere             state NEW
ACCEPT     icmp --  anywhere             anywhere             state NEW
ACCEPT     icmp --  anywhere             anywhere             state NEW
ACCEPT     tcp  --  anywhere             anywhere             tcp spts:1024:65535 dpt:28082 state NEW

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             192.168.40.17        tcp dpt:objcall
ACCEPT     all  --  anywhere             anywhere             state NEW
ACCEPT     all  --  anywhere             anywhere             state NEW
ACCEPT     all  --  anywhere             anywhere             state NEW
ACCEPT     tcp  --  anywhere             anywhere             tcp spts:1024:65535 dpt:28082 state NEW

If you notice, It has removed my DOCKER chain. Now when i am trying to run my nginx container, It gives me same error:

docker run --name nginx   -v /home/ashish/work/docker/nginx/conf/local.conf:/etc/nginx/conf.d/default.conf -v /home/ashish/work/docker/php:/app -p 80:80 --rm -itd  --network LEMP  nginx 

2dab94327ebbfb1849960df440cd8a1ba15b6253471b77838a5dce139b5cccdc

docker: Error response from daemon: driver failed programming external connectivity on endpoint nginx (df5852f12bb611dcf0057418e50b3f679efcbd81c91af6679c8e44b8a59fe4bf):  (iptables failed: iptables --wait -t filter -A DOCKER ! -i br-ee9760e3947e -o br-ee9760e3947e -p tcp -d 172.24.0.3 --dport 80 -j ACCEPT: iptables: No chain/target/match by that name.(exit status 1)).

Workaround which works for me:

Docker version:

docker -v

Docker version 18.09.0, build 4d60db4

Old machine kernel version:

uname -r

3.10.0-957.1.3.el7.x86_64

Taken another machine with different kernel version:

uname -r

3.10.0-862.2.3.el7.x86_64

o/p

It worked. No error occurred like above. Everything is running smoothly.

I changed my kernel of old machine and it worked for me. Although this is not good to change your kernel especially on production.

Had the same issue today. I ran docker-compose down and restarted the docker service which seemed to do the trick.

ERROR: for web_1  Cannot start service web: driver failed programming external connectivity on
endpoint web_1 (5694e5627dbac6cd543d65c764d4b9877fc67557b10f6f8a1f1e7170ffdc8314): 
Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8080:tcp:172.19.0.2:8080: input/output error

ERROR: for web  Cannot start service web: driver failed programming external connectivity on 
endpoint web_1 (5694e5627dbac6cd543d65c764d4b9877fc67557b10f6f8a1f1e7170ffdc8314): 
Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8080:tcp:172.19.0.2:8080: input/output error
Encountered errors while bringing up the project.

Hi, I am running Docker (v 18.09.0) and getting the following error when starting sandbox-proxy. Please help. C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint sandbox-proxy (fcc9a4c77b0de66ef7e8c8893b6eafb49f8071e7b9c3b1ce1def3a5e1434358d): Error starting userland proxy: Bind for 0.0.0.0:50111: unexpected error Permission denied. Have tried reinstalling/restarting docker/system, removing containers, etc. Nothing helped.

Try stopping docker and initiating it again on administrator mode. After it starts open power shell on administrator mode as well. Because the error says “permission denied” maybe this will solve your problem. Im not sure.

This does not solve the problem, I started the terminal and docker itself in Administrator mode and it still throws this exact same error.

Reset Docker to factory defaults

It helped me.

Same here 😦 Restarting docker for windows or sometimes stopping containers then docker system prune works

I encountered the problem on an AWS Ubuntu 16 Server. Simply sudo service docker restart solved my problems…

For anyone still coming here from Google: For my local dev machine it was just DHCP gave me a new lease and the docker service didn’t pick up on it and couldn’t create the network mappings anymore.

Had the same issue, seems like some containers was still running and blocking the ports.

do a “docker ps -a” to check if you have running containers run “docker kill $(docker ps -q)” to stop all running containers

I restarted docker and it worked sudo service docker stop then sudo service docker start

I’m getting a similar issue on OSX with a UDP port, removing local-kv.db doesn’t seem to be an option as the port remains stuck even when docker engine / VM is stopped but a reboot clears the bound port. Seems to be an issue on OSX side.

$ netstat -na|grep "\.53" <- no udp port 53 bound

$ docker run -p 53:53/tcp -p 53:53/udp --cap-add=NET_ADMIN --name dnsmasq -d andyshinn/dnsmasq:2.75

$ netstat -na|grep "\.53" udp4 0 0 *.53 *.* <- ok, it’s now bound

$ docker stop dnsmasq && sleep 2 && docker rm dnsmasq

$ netstat -na|grep "\.53" udp4 0 0 *.53 *.* <- remains!

$ sudo lsof -i -n -P|grep ":53" <- no output!

$ netstat -tulnvp udp|grep 53 udp4 0 0 *.53 *.* 196724 9216 1307 0 <- ok we have a pid

$ sudo ps aux|grep 1307 <- no matching pid!

Some old “zombie” process appears to be holding on to the port but I can’t figure out how to release it.

OSX 10.11.6

$ docker version Client: Version: 17.03.0-ce API version: 1.26 Go version: go1.7.5 Git commit: 60ccb22 Built: Thu Feb 23 10:40:59 2017 OS/Arch: darwin/amd64

Server: Version: 17.03.0-ce API version: 1.26 (minimum version 1.12) Go version: go1.7.5 Git commit: 3a232c8 Built: Tue Feb 28 07:52:04 2017 OS/Arch: linux/amd64 Experimental: true

I have the same problem

# docker-compose -f /etc/docker/docker-compose.yml up -d
Creating influxdb1

ERROR: for influxdb  Cannot start service influxdb: driver failed programming external connectivity on endpoint influxdb1 (a5ebc95f32f72421ae46eb5bdc4e2fbf0c10f43da61188cb75d1322546111c1a): Bind for 0.0.0.0:8086 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
# docker version
Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:50:14 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:50:14 2017
 OS/Arch:      linux/amd64
 Experimental: false
# docker-compose version
docker-compose version 1.11.1, build 7c5d5e4
docker-py version: 2.0.2
CPython version: 2.7.12
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016

Restarting docker service dosen’t help, the same with reboot of host machine.

I got the same problem. Deleted all the containers, network and local-kv.db + restart… now it works again.

Unfortunately running into the same issue today, running a Postgres container. Port in use error but the port isn’t used, ran all the diagnostic commands I could find to verify this. Restarting the Mac didn’t change anything. No way to rollback to the previous version, however, killing docker and restarting it with the following command seems to have fixed the issue:

killall Docker && open /Applications/Docker.app

MacOS user here. This problem usually happens randomly to me. No processes on the troubled port. Not even a single container, no vbox virtual machine up, nothing.

Restarting didn’t fix anything. Updating and restarting the Docker service using the Docker Desktop app fixed the issue. Not sure if this will fix the issue in the future.

@dmtanner thank you very much for your comment.

After upgrading packages on my system and rebooting I was stuck with docker trying to connect to IPv6 despite being disabled on my system.

Downgrading helped, the command is (in case someone is desperate and in a hurry)

apt install docker-ce=5:19.03.15~3-0~ubuntu-bionic
systemctl stop docker
systemctl start docker

EDIT: I did not realize that the issue was opened in 2016

In my case the problem is definitely with IPv6: up to and including version 19 the fact that it is disabled on my system was handled correctly, I upgraded today to 20.something and random issues with containers not starting because of that happened. Downgrading fixed everything (there were no changes in the configuration of the containers). I did not have messages about the “HOST being already used …”, just

ERROR: for 0aa9cd2e88ae_mqtt Cannot start service mqtt: driver failed programming external connectivity on endpoint mqtt (7123295e1d2a17d53a88c9847db30deac6888dcd6a27f7901b0b8a3dedff2cb6): Error starting userland proxy: listen tcp6 [::]:8883: socket: address family not supported by protocol

I was having this same issue w/ docker. docker service restarts and OS restarts even would not fix it. I am on Ubuntu 20.04.

when running docker-compose up kept getting this error: ERROR: for redis_1 Cannot start service redis: driver failed programming external connectivity on endpoint redis_1 (e55df4eefb70eh58dd408ac3a05385345a2eaa15a19aec555b629b91a77f0aeb): Error starting userland proxy: listen tcp6 [::]:5055: socket: address family not supported by protocol

and this warning: WARNING: Host is already in use by another container

docker-compose version 1.29.0, build 07737305 I tried with docker version 20.10.6 and I also tried 19.03.15 and they both have the same problem.

The only way I was able to fix this was by rolling back docker to 19.03.9.

I had the same problem today on my Ubuntu 20.04. This error just appeared. I think it was because of a recent update.

$ docker -v
Docker version 20.10.6, build 370c289

$ docker-compose -v
docker-compose version 1.25.0, build unknown

Additional information:

WARNING: Host is already in use by another container

important note: HOST is already in use.

Checking with ps and netstat the corresponding ports are free but on my system I have ipv6 disabled. Looks like Docker is trying to use ipv6 for whatever reason from now on??

Error starting userland proxy: listen tcp6 [::]:6379: socket: address family not supported by protocol

run;

systemctl restart docker

happened to be kernel networking debugging at the same time - a previous container instance was the culprit

iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8081 -j DNAT --to-destination 172.17.0.2:2342 ! -i docker0: iptables: No chain/target/match by that name.

was what gave it away when iptables couldn’t DNAT on the docker0 interface

@jamshid Can you post the o/p of sudo netstat -nlp | grep 8123. Thanks.

and sudo service {nameOfService} stop

As of today, using W10 still having this issue. Restarted docker, still have the issue. Closed docker and re opened, still have the issue.

None of the others solutions worked for me 😕

As illogical as it sounds, simply restarting the service worked.

(Did not need to clear any caches, old files or anything.)

I was having this issue on Ubuntu 18.04, same as for @Jason-2020, restarting the docker service freed the port for me as well in my system.

I have the same bug. So surprised this thread runs all the way till now.

For any one on windows, if you encouter this problem after waking up windows from sleep mode, restarting the computer solves the problem for me.
There was a previous similar issue about fast boosting on windows and I assume these two are related…

win + r > cmd(запуск от имени администратора) > netstat -aon | more дальше ищем локальный адрес с портом :8000, запоминаем PID, > ctrl + alt + del переходим во складку “Подробности” ищем процесс с ID как у PID > снимаем задачу(завершаем задачу) > restart your Docker > и заново запускаем (Run) свой docker-compose. Это должно решить проблему 2 вариант: просто откройте ваш docker-compose.yml и измените порт с 8000 на любой другой( ports: - ‘8000:80’) > Run you docker

Restarting docker every time for this issue is just a workaround. Indeed it solves the problem as it stops all the ports which might be occupied by containers. But the real problem is reported ports do not show up with netstat or with docker ps command, so it becomes a real headache to identify which container is using the port.

If anyone finds a way other than Docker Restart or disabling Fast Startup, please post here.

My issue was that I’d initialised a Docker Swarm on my machine for some experimentation. Everything went back to normal after running docker swarm leave --force

docker: Error response from daemon: driver failed programming external connectivity on endpoint sad_sanderson

None of these worked for me. Stopping the services (as described here) finally did the trick:

net stop docker net stop com.docker.service taskkill /IM "dockerd.exe" /F taskkill /IM "Docker for Windows.exe" /F net start docker net start com.docker.service "c:\program files\docker\docker\Docker for Windows.exe"

Got same issue.

My workaround (because that seem to be the only kind of solution) was to simply disable “Start Docker Desktop when you log in”. But keep it at start-up program in task management.

If you can’t find it in your task management you could place a shortcut in: %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

So my guess is that the way Docker uses the ‘Start Docker Desktop when you log in’ is not the way Windows 10 wants it.


Docker version: 18.09.2, build 6247962

Windows version: Windows 10 Pro Insiders Preview 1903, build 18898.1000

For Mac users: try stoing the httpd, apache services.

I have the same issue, that is related to IIS, so I have stopped that.

For me, it was because other containers were running using that port. I just changed the port mapping in docker-compose.yml, e.g for the memcache container service:

From:

  memcache:
    container_name: project_memcache
    image: memcached:latest
    ports:
        - "11211:11211"

To (external port next at 11212):

  memcache:
    container_name: project_memcache
    image: memcached:latest
    ports:
        - "11212:11211"

Had the same problem, simply restart docker fix it for me

I still have the same problem. It happens if you have enabled Fast Startup (enablede by default) in Windows 10. You can disable it -> https://www.windowscentral.com/how-disable-windows-10-fast-startup and then you will not need to restart docker every day. But it’s just a work around…

I solved it by updating windows build from 1803 to 1809

Same issue here - in my case apache running on port 80 was the problem.

restart docker can resolve everything, that because restart docker would clean up all the running container.

I check my docker compose.yml file again, and delete the container which located inside the docker-compose.yml file either, and no need to restart the docker.

enjoy.

This worked for me Thnks! 😃

I have the same issue and it can be solved by restarting docker.

restarting docker service helped me to resolve this issue.

version 18.09.0

Yeah, restarting does work but it’s still really annoying, I have to do that every time I want to launch Docker…

Disabling Fast Boot on Windows 10 helps

I had same problem on Mac OS Sierra 10.12.6. Docker version 18.03.1-ce.

I solved it by applying @a14m suggestion: Soution: lsof -nP +c 15 | grep LISTEN

com.docker.vpnk 35957   18u     IPv4        0t0       TCP *:7501 (LISTEN)
com.docker.vpnk 35957   19u     IPv6        0t0       TCP [::1]:7501 (LISTEN)

Find the process that is listening to the blocked port and kill it: kill -9 <PROCESS_ID>. For me it was: kill -9 35957

Then restart Docker and it’s all good

I could attach any service to any port. For some reason the error message was showing me an IP address I didn’t recognise. I restarted Docker (Windows) and it worked from thereon.

As pointed out earlier. This is not a compose issue, it is a Docker issue. Hence why this is closed. There is an issue open for this in the Docker repo.

Windows 10 have something like fast boot. Probably this is a issue. On another PC without fast boot it works well.

wt., 22 maj 2018, 20:25 użytkownik rangeoshun notifications@github.com napisał:

I had similar issue with my nginx server. To resolve I had to:

docker stop $(docker ps -qa)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/compose/issues/3277#issuecomment-391092688, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGaX_NDPkbWf08T2wOkq1PjQz4v-ES3ks5t1FgPgaJpZM4IBfG_ .

@IGZmanuelMartinVivaldi I have same problem as @NoICE. I have to restart docker all the time after windows is fully booted. It was in Fall Creators update and the current one.

PS. I’m using docker compose, any my docker compose file uses version 2.

@NoICE looks like its a problem that started with the Windows 10 Fall Creators update, but I don´t know it will be fixed in the current Spring update or in the new Dockers versions

@IGZmanuelMartinVivaldi thanks this works

I was modifying some iptables configs. And encountered this error. Restarting the docker daemon fixed it…

Starting 4b77a68f3777_deploy_nginx_1 ... 
Starting 6b96d171e3eb_deploy_database_1 ... 
deploy_fpm_1 is up-to-date
Starting 4b77a68f3777_deploy_nginx_1 ... error

ERROR: for 4b77a68f3777_deploy_nginx_1  Cannot start service nginx: b'driver failed programming external connectivity on endpoint 4b77a68f3777_deploy_nginx_1 (0efc2656fd512a2102e7ab82391048a6f5b9503819139096739d443a5b2553b0):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 443 -j DNAT --to-destination 172.18.0.Starting 6b96d171e3eb_deploy_database_1 ... error

ERROR: for 6b96d171e3eb_deploy_database_1  Cannot start service database: b'driver failed programming external connectivity on endpoint 6b96d171e3eb_deploy_database_1 (39fe9b0f86582e35df2c279dc2619f660008b6c3928e293744e005d5eca8245f):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 5432 -j DNAT --to-destination 172.19.0.2:5432 ! -i br-53878ee15994: iptables: No chain/target/match by that name.\n (exit status 1))'

ERROR: for nginx  Cannot start service nginx: b'driver failed programming external connectivity on endpoint 4b77a68f3777_deploy_nginx_1 (0efc2656fd512a2102e7ab82391048a6f5b9503819139096739d443a5b2553b0):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 443 -j DNAT --to-destination 172.18.0.3:443 ! -i br-9c08ee804427: iptables: No chain/target/match by that name.\n (exit status 1))'

ERROR: for database  Cannot start service database: b'driver failed programming external connectivity on endpoint 6b96d171e3eb_deploy_database_1 (39fe9b0f86582e35df2c279dc2619f660008b6c3928e293744e005d5eca8245f):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 5432 -j DNAT --to-destination 172.19.0.2:5432 ! -i br-53878ee15994: iptables: No chain/target/match by that name.\n (exit status 1))'

I am using Windows 10.0.16299.125, Docker for Windows 17.12.0-ce (15139) and Linux containers. I turned off Skype and the error driver failed programming external connectivity on endpoint is gone. Here is my docker-compose.yml:

version: '3'

services:
  identity.api:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
    ports:
      - "80"

I’ve been continuously having this issue. The strange thing is i get ERR_SOCKET_NOT_CONNECTED in the browser when trying to access the service. Then i stop the container and try to start it again is when I get the error you are reporting.

Resarting the Docker engine fixes the issue, but it comes back shortly after.

After some digging i realized that my containers can communicate with each other via the internal IP addresses Docker assigns, but cannot communicate with the outside world (even google and such).

This could happen after 10 minutes, or after 2 hours of use.

I’m on MacOS High Sierra and the latest Docker for Mac.

Same error - same remedy - restarted Docker on Mac then reran command and it worked.

This might be an obvious thing to try, but I had this error, but I restarted Docker itself, and then started the containers and the error went away.

I had this happen to me. The port mapping didn’t show up when I did netstat -an on an Elevated Powershell prompt, though I didn’t try the same from within the VM. I had to restart Docker for Windows to remediate. This recreates the underlying VM as well.

Deleting the /var/lib/docker/network/files/local-kv.db file and restarting docker also fixed this issue for me on Ubuntu

@marcelmfs you are absolutely correct! thank you so much for that.

@madjam002 Thanks for this fix! this has been bugging me for a couple of months on Docker for Mac, i’ve had to resort to resetting to factory settings but running this in conjunction with restarting the xhyve vm has released those ports again.

@madjam002 yes except the last line, that is i did not run docker run --rm -v /var/lib/docker/network/files:/network busybox rm /network/local-kv.db because you said you haven’t tested this and I don’t know what the implications of deleting all those files will be, so I didn’t delete them because I want to see if I can fix this without removing and reinstalling docker from scratch.