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

Created on 6 Apr 2016  ·  278Comments  ·  Source: docker/compose

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

arenetworking

Most helpful comment

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

All 278 comments

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

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

same thing happening to me.

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

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
`

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

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 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?

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

I too am getting this after upgrading to Docker 1.12-rc2, not sure if this is the right place to post this.

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:   906eacd-unsupported
 Built:        Fri Jun 17 21:12:28 2016
 OS/Arch:      linux/amd64
 Experimental: true

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'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

I've also been getting the same error as you guys. I believed it was because nginx was binding it ports that were already taken up but I don't think so now. Did anyone find any solutions to this? :)

+1 Same error on mac

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.

+1 have the same problem on mac

@TuningGuide MacBook Pro (15-inch, Late 2011), 2.2 GHz Intel Core i7, 8GB 1333 MHz DDR3
Running Node 4.4.7 extended to support Ember CLI. Setup is below:

FROM node:4.4.7

# expose ember-cli ports
EXPOSE 4200 35729 49152

# install ember-cli dependencies
RUN npm install -q -g ember-cli
RUN npm install -q -g bower
RUN npm install -q -g phantomjs-prebuilt

# install watchman
# http://ember-cli.com/user-guide/#watchman
RUN \
  git clone https://github.com/facebook/watchman.git &&\
  cd watchman &&\
  git checkout v3.5.0 &&\
  ./autogen.sh &&\
  ./configure &&\
  make &&\
  make install

Ran with mounted volume of the ember-cli files using 'ember serve' as the command.

+1 same problem on the mac with docker for mac

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

➜  ~ docker info
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 2
Server Version: 1.12.0-rc3
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 21
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.14-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.954 GiB
Name: moby
ID: GZAT:26TX:PYCM:KKNA:JSWY:AMEL:RQYI:O23B:QGSQ:WBVB:3Q7E:XDPJ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 18
 Goroutines: 30
 System Time: 2016-07-08T17:41:26.03558348Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
➜  ~ cat docker-compose-local.yml
version: '2'
services:
  cache:
    image: redis
    command: redis-server --appendonly yes
    ports:
      - "6379:6379"
  db:
    image: postgres:9.4
    ports:
      - "5432:5432"
    volumes:
      - ./tmp/dump.gz:/tmp/dump.gz
      - ./tmp/dump.sh:/docker-entrypoint-initdb.d/dump.sh
    environment:
      POSTGRES_DB: dbname
      POSTGRES_USER: dbuser
      POSTGRES_PASSWORD: dbpass

Got next errors:

ERROR: for cache  driver failed programming external connectivity on endpoint carsaver_cache_1 (253054ef6864bdcb5377bd1690173fa352021d505dc05c3aafecf66b02c0b73d): Error starting userland proxy: write /port/tcp:0.0.0.0:6379:tcp:172.18.0.2:6379/ctl: errno 526

ERROR: for db  driver failed programming external connectivity on endpoint carsaver_db_1 (8a5990bd06a50d87c7db96de84367bb01b71c971d5a4b9e578fea7d75d893d59): Error starting userland proxy: write /port/tcp:0.0.0.0:5432:tcp:172.18.0.3:5432/ctl: errno 526
ERROR: Encountered errors while bringing up the project.

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.

@miraage happy to hear you solved your issue.
I didn't have your volume data+dump.sh but did a quick compose without issues:

Creating driverfailed_cache_1
Creating driverfailed_db_1
Attaching to driverfailed_cache_1, driverfailed_db_1

@jamshid Why are you specifying an IP for socat (not familiar with it)? How are you using it?
Doing a docker-compose up without the IP I don't have any issues:

Creating socat_httpcache_1
Creating socat_socat_httpcache_1
Attaching to socat_httpcache_1, socat_socat_httpcache_1
docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
f2e3b3767982        bobrik/socat        "socat TCP-LISTEN:812"   2 seconds ago       Up 1 seconds        0.0.0.0:8123->8123/tcp   socat_socat_httpcache_1
43dbd35629e0        clue/polipo         "polipo proxyAddress="   3 seconds ago       Up 2 seconds        8123/tcp                 socat_httpcache_1

If your goal is for your http_cache to talk to the socat container, why not put them on the same network and be done with it?

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
    networks:
      - socatnet

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

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.

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 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.

For me it was squid, I stopped squid and didn't see that anymore. So I think it may have to do with whatever is taking up the port and if we force docker to map that port.

Same here as @marcosalberto and others. The post I was trying to mount postgres to was already being used. I just changed the port and things worked quite well.

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

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!

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')

+1 on Mac

@mad-raz great work-around! thanks!

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

+1 here, too.

Tried the workaround @mad-raz suggested, and it cleared out all of the reservations, but they come back after a few seconds. Looks like the com.docker.slirp process is getting re-spawned by a watchdog service. As a result, the error surfaces on the next docker-compose up.

driver failed programming external connectivity on endpoint ... Bind for 0.0.0.0:9086 failed: port is already allocated

docker-compose version 1.8.0-rc2, build c72c966

After shutting down Docker for Mac, these processes remain.
% ps -ef | grep docker !10007 0 1086 1 0 Tue03PM ?? 0:00.01 /Library/PrivilegedHelperTools/com.docker.vmnetd 648074730 30807 1 0 1:49PM ?? 0:00.07 /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux -watchdog fd:0 648074730 30808 30807 0 1:49PM ?? 0:00.03 /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux -watchdog fd:0 648074730 30810 30807 0 1:49PM ?? 0:02.08 com.docker.db --url=file:///Users/astone/Library/Containers/com.docker.docker/Data/s40 --git /Users/astone/Library/Containers/com.docker.docker/Data/database

+1 on mac :(

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

Thank you @alexander-emelyanov !
I suddenly got this error while running docker-compose up -d for my project on OS X and did not made the relation to the fact I had installed PHP 7 on my Mac (so that SublimeText syntax checks work correctly) with the Liip scripts the same day.

It was indeed due to Apache getting started on my Mac, and I just had to stop it.

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.

Read up there's a workaround explaining exactly that https://github.com/docker/compose/issues/3277#issuecomment-232505775

@mad-raz When killing the process, Docker (for Mac) automatically immediately restarts, and the same ports are used again just a few seconds after...

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

This issue is really two issues:

  1. There's a confusing error message when a port is already in use by another application (e.g. Apache). That's been fixed in Docker 1.12.0 (it now explicitly says "port is already allocated").
  2. After stopping containers, the ports they use are sometimes still mapped on localhost.

Is anyone still experiencing issue no. 2 after upgrading Docker for Mac to the latest version (1.12.0, or 1.12.0-beta21 if you're on the beta channel)?

I'm still getting this issue.
Docker v1.12, Docker Compose v1.8.

Got an nginx service which just won't start, as well as various others which occasionally fail:

ERROR: for nginx  Cannot start service nginx: driver failed programming external connectivity on endpoint test_nginx_1 (3f72f35baab64b37c667a4a98e9b8c4adc312e2df7a16c80030536101c695546): Bind for 0.0.0.0:80 failed: port is already allocated

Tried restarting, downing the whole project and recreating, but nothing is working.

Output of sudo netstat -tulpn | grep 80:

tcp6       0      0 :::80                   :::*                    LISTEN      3455/dockerd

Docker info:

Containers: 30
 Running: 30
 Paused: 0
 Stopped: 0
Images: 89
Server Version: 1.12.0
Storage Driver: btrfs
 Build Version: Btrfs v4.4
 Library Version: 101
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge null host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: apparmor seccomp
Kernel Version: 4.4.0-31-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 9.765 GiB
Name: apps
ID: 7WCN:K7EU:M6IO:NPF2:UK2W:HBKO:MUSD:V7FC:RNWU:3FSA:BNAR:TZEH
Docker Root Dir: /mnt/storage/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Insecure Registries:
 127.0.0.0/8

Version:

Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 22:11:10 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 22:11:10 2016
 OS/Arch:      linux/amd64

It's worth noting that my compose project has 29 services in it.

Also it's strange that when Docker is hanging on to port 80 for no reason, I can't connect to port 80 from another host. When port 80 is legitimately in use by a container, port 80 can be accessed externally just fine.

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)...

My issue is not a configuration issue (at least I don't think it is).
I can restart the Docker Daemon and restart all my containers and every time it will be different containers which fail with the error. Seems to be a bug in Docker hanging onto ports it shouldn't be.

In my case above with nginx, even if I remove the nginx container and restart the docker daemon, docker is still listening on port 80 and 443 :/

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.

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

This is also happening with docker 1.12.0, docker-compose 1.8 and swarm 1.2.4 on ubuntu. Using consul for kv. endpoint join on GW Network failed: driver failed programming external connectivity on endpoint gateway. The container where the error happens stays in a created state until you clean it up.

Same error on Debian:

# docker version
Client:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:02:53 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.1
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   23cf638
 Built:        Thu Aug 18 05:02:53 2016
 OS/Arch:      linux/amd64
# docker-compose up -d
Starting elk_elk_1

ERROR: for elk  driver failed programming external connectivity on endpoint elk_elk_1 (8b8bb61b786bd1e07fa83c39a14338cab6c594cdfe74890c36e32ed9de33d8d9): Bind for 0.0.0.0:12201 failed: port is already allocated
# netstat -nl -p tcp  | grep 12201
udp6       0      0 :::12201                :::*                                14055/docker-proxy

same error on ubuntu 16.04LTS.

docker version
Client:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built: Thu Aug 18 05:33:38 2016
OS/Arch: linux/amd64

Server:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built: Thu Aug 18 05:33:38 2016
OS/Arch: linux/amd64

docker-compose version
docker-compose version 1.7.1, build 0a9ab35
docker-py version: 1.8.1
CPython version: 2.7.9
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013

Step 3 : RUN rm /etc/nginx/conf.d/default.conf
---> Using cache
---> 18fabfe71380
Step 4 : ADD default.conf /etc/nginx/conf.d/
---> Using cache
---> ad8c17a883c9
Successfully built ad8c17a883c9
Creating uauth_fpm_1
Creating uauth_redis_1
Creating uauth_web_1

ERROR: for web driver failed programming external connectivity on endpoint uauth_web_1 (1a1e10881709d37b7b242f43dca561802ddf19d67f713cfd05eb2cdae3c4b0c0): Bind for 0.0.0.0:443 failed: port is already allocated
Traceback (most recent call last):
File "", line 3, in
File "compose/cli/main.py", line 63, in main
AttributeError: 'ProjectError' object has no attribute 'msg'
docker-compose returned -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 can't find the file /var/lib/docker/network/files/local-kv.db. Where can I find souch file? I'm using El Capitan 10.11.4 and Docker for Mac 1.12.

@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 👍

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

At @aanand I am still experiencing issue no. 2, that is After stopping containers, the ports they use are sometimes still mapped on localhost.
I am on Ubuntu 14.04 and docker Version: 1.12.0

Running docker-compose up after stopping and removing containers throws the error below for the official postgresql image:

 ERROR: for db  Cannot start service db: driver failed programming external connectivity on endpoint postgres (a0edc4146637dea0b4641f06f74a38be7977259142136faee2bd0f0e8f7d6a36): Bind for 0.0.0.0:5432 failed: port is already allocated
 ERROR: Encountered errors while bringing up the project.

This is what netstat shows:

 sudo netstat -nlp | grep 5432

 tcp6       0      0 :::5432     :::*    LISTEN

@mad-raz fix for mac did not work for me on Ubuntu. Has any solve this on Ubuntu

@mankind Have you tried either of my fixes mentioned above?

@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.

@mankind It's the last line which will actually perform the fix. Running the command will remove all of your networks from Docker which is a destructive operation, but it's the only way that I'm aware of to fix this issue. It's the exact same command as what I posted earlier on in this thread, the only difference being that you're running it inside a Docker container instead of on the host.

To clarify, you will need to remove all your containers and run the command which will remove all of your networks, but you will keep your Docker images if that's what you're worried about.

@madjam002 thanks for clarifying.

I got the same error as described by many people in this thread; however my problem/solution was different from everyone else's.

I'm using docker-machine on my mac. I have multiple projects that use docker. I use one machine and just use docker-compose per project to start my containers up in this one machine. The issue I found was that, I was trying to start up my containers for one project (project b), but containers for another project (project a) were running for some reason (not sure why).

Specifically, I was getting errors that I couldn't bind to port 80 and 3306 because as I was starting up project b containers, project a were already running and binding themselves to those ports.

I just used docker ps -a to verify that other containers were running and already bound to those ports. Stopping those containers resolved the issue for me.

The main problem I see here is the these containers from project a keep starting up without me actually starting them.

Hope this helps anyone else with this issue.

The same issue fixed stopping another app on the same port , check the app is using your port with netstat -anp | grep PORT (replace PORT with the one you are using) or use a different port. That fixed for me.
I hope this help anyone.

@ragboyjr maybe you've started project a containers with docker-compose up -d and have restart: always on your compose files.

@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.

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.

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

+1 same here, restarting docker for mac fixes it

Docker For Windows just told me to update, so I did. Now my containers won't start. Fresh reboot, fresh Docker Restart, no containers running. Database won't launch:

~
Error response from daemon: driver failed programming external connectivity on endpoint db (44309324c7301ee0bba984b7bfee01201939c809b98f3d10333258d09d243931): Error starting userland proxy: Bind for 0.0.0.0:3306 failed: port is already allocated
Error: failed to start containers: db
~

D4W Version 1.13.0 (9795)

Off to research how to install the old version.

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



md5-a7d154bb42b823b1b35a4de5ba377ae0



# 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.

Just ignore previous entry as it was my fault ( typo )

I've got the same problem (openSUSE 42.2). Removing the /var/lib/docker/network/files/local-kv.db file fixed the issue.

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

Nevermind, issue is still there

for me it was brew nginx. once I stopped it, docker worked again.

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

Can only confirm this is happening to me as well on multiple containers.
OSX
➜ ~ docker version
Client:
Version: 17.03.1-ce-rc1
API version: 1.27
Go version: go1.7.5
Git commit: 3476dbf
Built: Fri Mar 17 00:27:41 2017
OS/Arch: darwin/amd64

Server:
Version: 17.03.1-ce-rc1
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: 3476dbf
Built: Wed Mar 15 20:28:18 2017
OS/Arch: linux/amd64
Experimental: true

A few times it has resolved it self with a docker-compose build and another time by restarting the docker process.

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

Similar issue on Ubuntu 16.04.2 LTS, Docker version 17.04.0-ce, build 4845c56

$ docker run -p IP:80:3000 --link tribeca-mongo:mongo --name tribeca -d tribeca
29a0cac17720e203e4392b281460732dc5fe43c72e34bc7365760f8bba9dc348
docker: Error response from daemon: driver failed programming external connectivity on endpoint tribeca (54911841811bf7fb7b8b6b866eae2b790fe1b8b3bd18ccd0bb2089b565538c6c): Error starting userland proxy: listen tcp IP:80: bind: cannot assign requested address.

ubuntu same issue

Mac 10.12.3 same issue

Windows 10, same issue

Mac 10.12.3 (16D32), same issue
ERROR: Encountered errors while bringing up the project.

Windows 10, same issue

docker info
Containers: 4
Running: 3
Paused: 0
Stopped: 1
Images: 7
Server Version: 17.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc
runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.13-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 6.538 GiB
Name: moby
ID: HVV7:ECOB:GSCQ:UHGE:MUHA:GVD5:KS3W:YVJ5:DJ5E:AJIM:OHMR:344T
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 36
Goroutines: 39
System Time: 2017-05-11T09:41:16.7020554Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://mhihpv4t.mirror.aliyuncs.com
Live Restore Enabled: false

just run : docker run -d -p 3142:3142 --name blaName Bla_imageID
without ip and then run docker container ls to have it ip address and then connect to it.

For me it work ! on new version of docker on MAC

For those who want to specified a specific address

Create your docker network :
docker network create --subnet=172.18.0.0/16 mynet123

then simply run the image (I'll take ubuntu as example)
docker run --net mynet123 --ip 172.18.0.22 -it ubuntu bash

Had this same issue on Windows Docker + WSL and this article helped solve it:
https://www.mikeplate.com/2011/11/06/stop-http-sys-from-listening-on-port-80-in-windows/

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

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

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

Same on ubuntu 16.04 via docker-compose.
# docker -v Docker version 17.03.1-ce, build c6d412e

Restart of docker daemon worked but it's kinda sad.

This problem maybe is related to libnetwork. I have made a PR(https://github.com/docker/libnetwork/pull/1794). Hope it can be helpful.

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.

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.

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

I have this problem persisting on our CI system - "random" builds are broken, because of this error. It was working fine a few weeks ago, then it started to appear randomly. Restarting docker seems to help, but it's still an unreliable solution for a CI system.
Sadly i don't have at hand any information when it started to happen, i suspect when I've updated from "old" pre-moby docker package to docker-ce, but it's just a guess now

@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) << 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

I've the same problem on Mac 10.12.5 (16F73):

Version 17.03.1-ce-mac12 (17661)
Channel: stable
d1db12684b

But no problem for the same docker image on Linux:

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:    16.04
Codename:   xenial

Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:14:09 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:14:09 2017
 OS/Arch:      linux/amd64
 Experimental: false

same error

Docker version 17.06.0-ce, build 02c1d87

Workarounds for me were to stop, remove and re-run containers. If that fails, stop and restart docker and try again. If that fails, reboot, rebuild docker images and re-run containers.

I just had to stop apache and run docker-compose up again.

Simply restarting docker fixes this issue for me.

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

If the error you getting is Redis related. ensure that you not running Redis for Windows/Linux/etc in the background and/or on start up

Shutting down Docker via the menu / Restarting via the menu didn't fix the issue for me as it doesn't seem like Docker really get's stopped completely.

I ran sudo pkill -fi docker and subsequently reopened docker and it was fixed.

An issue on docker-for-mac again (not seen in previous release, 17.06.0-ce-mac18 (18433) ):
docker info Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 17.09.0-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0 runc version: 3f2f8b84a77f73d38244dd690525642a72156c64 init version: 949e6fa Security Options: seccomp Profile: default Kernel Version: 4.9.49-moby Operating System: Alpine Linux v3.5 OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 7.787GiB Name: moby ID: DTSR:I2Q4:V6L7:XGCE:YFZJ:UASU:47JH:K3K3:ZALX:DJQL:YM5O:GC64 Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): true File Descriptors: 20 Goroutines: 32 System Time: 2017-10-11T08:37:39.082141259Z EventsListeners: 1 No Proxy: *.local, 169.254/16 Registry: https://index.docker.io/v1/ Experimental: true Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false

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 am facing same issue in mac version 17.09.0-ce-mac35 (19611)

Try the solution way up the thread by madjam002. If that doesn’t work, export all your custom images or insure that they can be rebuilt with Dockerfiles, then completely rmi all your images, uninstall Docker, reboot, and reinstall Docker, but it may happen again. A workaround is to change your config to a different port. When I did that occasionally the new port would again become stuck and I’d have to change the config to a third port. It’s not clear why this happens to some people and not others.

On MAC stop internal apache

sudo apachectl stop

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.

@rogoit that solved the issue for me. thanks!

sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist works for me on mac

When I get this error, I've had success visiting the /port directory in the host:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
cd /port/tcp:0.0.0.0:5000:tcp:172.18.0.16:3000  # or whatever file had the file exists error

In my case there was file in that directory - I think it was called ctl or similar, and after I ran cat on that file to see what was in it, the issue went away - the file, and the directory disappeared too after a cd .. and ls.

I could then run docker-compose start [service].

Version 17.09.0-ce-mac35 (19611)
Channel: stable
a98b7c1b7c

macOS 10.13.1 (17B1003)

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.

@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.

just do it;

sudo apachectl stop

I've never had it on Windows but when switch to Mac I had this error. Restarting Docker didn't change anything. The solution was changing port for apache in Mac from default 80 to other (and obviously restarting apache). After this problem disaappeared.

I'm aware this thread still generates a lot of discussion, but I'm going to close it as it has nothing to do with Compose per se. As it has been pointed out in multiple comments, make sure you don't have host applications already binding the port your service is trying to expose (Apache is a common offender).

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.

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.

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

systemctl stop firewalld
systemctl restart docker

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

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

Yup, also had this problem with Docker for Windows. Restarting Docker fixed it.

Also encountered this multiple times today and yesterday with Docker for Windows. Restarting Docker did not fix it 😅

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.

That also worked for me.

Is there anything I can do (collect more logs, send diagnostics ID) to help investigate this?

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

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

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 had completly forgot that I had a Valet running on start. Basicaly just check every ports and stop anything else runing before launching docker.

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))'

Was facing this issue right now on vagrant box.reloaded vagrant box issue was fixed.

same issue Windows 10

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

@gudge25 @magomedov I'm not sure if this is related, but 18.03-rc3 just got released and it contains this fix. Might be worth updating to see if that build fixes the issues people are having here.

Edit: I just tried out my project which used to suffer from this problem after a restart. After 20 mins of testing, I can no longer reproduce the issue.

my solution was -> Reset Docker to factory defaults

every time i startup my computer, start my container, i see this error.
Error response from daemon: driver failed programming external connectivity on endpoint ea-mysql (4bf1d5fc80663ac6ceabb68283b7a31860672826709d73aecaeaaa8f50be69ff): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:3306:tcp:172.17.0.2:3306: input/output error
Error: failed to start containers: b

restart computer, start again, it works.

PS C:Usersphucnv7> docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 2
Server Version: 18.03.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d347405
ID: 7SDD:BOPB:ZIQ4:XO2T:AMRA:BGMS:XKB7:EHGH:K73W:2Y4D:SLCW:Z5DX
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 19
Goroutines: 36
System Time: 2018-03-28T01:25:45.5754181Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

I think I may have figure this one out guys, it's really dumb... I am on a mac and have 2 separate user accounts both running docker. After quitting docker on the other account, I came back tried the lando start command and it worked beautifully.

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

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

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?

@IGZmanuelMartinVivaldi thanks this works

@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 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.

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

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

Same issue here

I am trying to resolve the same issue for the last two days but so far no success. It happens on Windows 7, docker toolbox, AWS SAM CLI & Eclipse.

+1 same problem on windows 10

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

docker stop $(docker ps -qa)

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_
.

EDIT: It is me being blind. There was a typo in port number in my configuration.

Same problem - Bind for 0.0.0.0:18305 failed: port is already allocated.
But Port is not allocated. Checked with sudo lsof -i -P -n, and service can be stated without problem when docker is not used.

Version: 18.03.1-ce-mac65 (24312)
Channel: stable
93354b38bd

Restart is not helping.
Reset to factory defaults is not helping.

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.

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.

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.

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

Disabling Fast Boot on Windows 10 helps

Restarting docker works

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

Reset Docker to factory defaults

It helped me.

it help me by reset Docker.

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

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.

I have Windows 10 Pro both on a laptop and desktop with the exact same issue. I'm currently running version: 18.06.1-ce, but at least the last 2 previous versions had the same behavior. This is a consistent and easily reproducible issue, occurring on a very common configuration.

Are we all doing something wrong, or is this something that requires fixing?

You can check also with ACTIVITY MONITOR on OSX. I saw this problem when another user is logged in and is using Docker. Kill the processes or logout and it will work.

I had this happen on docker for windows with nginx. I restarted docker and do not see it now. Of course it will probably be there if I remove then create a new container for nginx.

I had the same problem (starting a nginx reverse proxy on port 80) on Windows 10, maybe caused by a previous virtual box installation.

Resetting docker to factory defaults (rightclick icon in notification area -> settings -> reset) fixed it for me.

restart docker work for me. on windows 10

thx @ballmdr , that`s works for me either.

I was getting the same issue. Port 80 was being used by IIS.

1) Hit Run, type - 'inetmgr' which opens up IIS
2) On Actions (Top Right) - Click 'Stop'
3) Do Docker run again

I was getting the same issue on MAC moJave after updating docker-compose. Simply restarting docker fixes the issues for me.

Same here, I have macOS Mojave and restarting fixed issues.

@makproductions thanks.

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

Ubuntu 18.04, restarting docker solve the problem

The problem still exists on Windows in 18.06.1-ce-win73 (19507) Plase re-open this.

Usually happens since postgresql is running and using port 5432 try stopping the service and running the docker-compose up --build so it will do the initialization..

sudo service postgresql stop
docker-compose up --build

should work

madjam002

1.docker rm -f all containers.
2.docker network rm network interfaces.
3.sudo rm /var/lib/docker/network/files/local-kv.db

I tried this now I am stuck with another problem as docker: Error response from daemon: failed to update store for object type *libnetwork.endpointCnt: Key not found in store.. How to solve this problem, can you suggest me.... Thanks.

I'm aware this thread still generates a lot of discussion, but I'm going to close it as it has nothing to do with Compose per se.

This is a docker issue - not a docker-compose issue. This issue is closed, so isn't going to gain any traction. There are several issues already open in the main docker repo. Comments should probably go there:

See https://github.com/docker/for-win/issues/2722
and https://github.com/docker/for-win/issues/1967

@shin- Should this be locked?

I get the same error in the following situation:
Docker 18.06.1, Docker Compose 1.22.0, Ubuntu 18.04

Starting d1df6864f98d2599_api_1 for d1df6864f98d2599_api_1 Cannot start service api: driver failed programming external connectivity on endpoint d1df6864f98d2599_api_1 (6b3f4a9c68d6858ace2b39a0296ed41620ff3007b14c2379b539397267228f7d): Bind for 0.0.0.0:5000 failed: port is already allocated

When I start the containers using docker-compose from command line, the container is called src_api_1, because I'm running the command from a src folder.

When I run docker-compose from TeamCity, the container is called d1df6864f98d2599_api_1 and I get that error.

The command is docker-compose -f src/docker-compose-production.yml up -d api.

I just changed my port number in .yaml file and it started working for me.

In my case, it was because windows login password was updated and apparently the new password was not updated to docker. I had to go to docker for windows -> settings -> shared drive, uncheck shared drives, click apply, and then check again and apply, it will then prompt for password. After I enter the password, it's is working again.

This is continuing to plague my setup. Restarting docker does not free up the port on OSX. Restarting the host machine does free up the port.

I got the same error message, but my problem was caused by working on two different pages at the same time.

When switching from one too the other I forgot to use docker-compose down,

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 (Deallocate the port by removing that container)
  3. Assing your new container with your port number

@ronakganatra9 hey, i have a question where could you find your own port in .yaml file ?

```PS C:UsersMouazDesktopfernandroidstf-poc> docker-compose up
stf-poc_storage-temp_1_20d132e37939 is up-to-date
stf-poc_dev-triproxy_1_7224046ecd68 is up-to-date
stf-poc_auth_1_f76f43d5e179 is up-to-date
stf-poc_rethinkdb_1_6e5e0628f86c is up-to-date
stf-poc_triproxy_1_7d61645de13d is up-to-date
stf-poc_adb_1_53f170a2d9ae is up-to-date
stf-poc_storage-plugin-apk_1_efbbfa2dc680 is up-to-date
stf-poc_storage-plugin-image_1_ebc249ed0769 is up-to-dateStarting stf-poc_migrate_1_ebc2c2157fdf ...

Starting stf-poc_migrate_1_ebc2c2157fdf ... done

stf-poc_api_1_713c609d74d5 is up-to-date
stf-poc_reaper_1_cca8849d63b8 is up-to-date
stf-poc_websocket_1_a41866f85947 is up-to-date
stf-poc_app_1_db0fc2088323 is up-to-date
Starting e3e9585e6a3a_stf-poc_provider_1_6961669e5bb1 ... error

ERROR: for e3e9585e6a3a_stf-poc_provider_1_6961669e5bb1 Cannot start service provider: b'driver failed programming external connectivity on endpoint e3e9585e6a3a_stf-poc_provider_1_6961669e5bb1 (6033aa098528aac29e541b1d52303e4106c0f7a760222995b4c0b348a7d76941): Error starting userland proxy: Bind for 0.0.0.0:7680: unexpected error Permission denied'

ERROR: for provider Cannot start service provider: b'driver failed programming external connectivity on endpoint e3e9585e6a3a_stf-poc_provider_1_6961669e5bb1 (6033aa098528aac29e541b1d52303e4106c0f7a760222995b4c0b348a7d76941): Error starting userland proxy: Bind for 0.0.0.0:7680: unexpected error Permission denied'
ERROR: Encountered errors while bringing up the project.
PS C:UsersMouazDesktopfernandroidstf-poc> docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d46b94a05e8b stf-poc_nginx "/entrypoint.sh" 2 minutes ago Restarting (1) 38 seconds ago stf-poc_nginx_1_4c61f58776f1
6674d0116aa9 openstf/stf:latest "stf storage-plugin-…" 2 hours ago Up About a minute 3000/tcp stf-poc_storage-plugin-image_1_ebc249ed0769
df2e7c721d55 openstf/stf:latest "stf storage-plugin-…" 2 hours ago Up About a minute 3000/tcp stf-poc_storage-plugin-apk_1_efbbfa2dc680
a697ef5e309b openstf/stf:latest "stf app --auth-url …" 2 hours ago Up About a minute 3000/tcp stf-poc_app_1_db0fc2088323
fefaebe9340a openstf/stf:latest "stf websocket --por…" 2 hours ago Up About a minute 3000/tcp stf-poc_websocket_1_a41866f85947
8a1fd41fa92d stf-poc_storage-temp "stf storage-temp --…" 2 hours ago Up About a minute 3000/tcp stf-poc_storage-temp_1_20d132e37939
c7f48e1b4d74 openstf/stf:latest "stf reaper dev --co…" 4 hours ago Up About a minute 3000/tcp stf-poc_reaper_1_cca8849d63b8
293d4cf18ddb openstf/stf:latest "stf api --port 3000…" 4 hours ago Up About a minute 3000/tcp stf-poc_api_1_713c609d74d5
257667df032e openstf/stf:latest "stf processor --con…" 4 hours ago Up About a minute 3000/tcp stf-poc_processor_1_9c46a2ef3b9d
e065f41e2f61 rethinkdb:2.3 "rethinkdb --bind all" 4 hours ago Up About a minute 8080/tcp, 28015/tcp, 29015/tcp stf-poc_rethinkdb_1_6e5e0628f86c
522eb78fc46a sorccu/adb:latest "/sbin/tini -- adb -…" 4 hours ago Up About a minute 5037/tcp stf-poc_adb_1_53f170a2d9ae
44e03f74b098 openstf/stf:latest "stf triproxy app --…" 4 hours ago Up About a minute 3000/tcp stf-poc_triproxy_1_7d61645de13d
32f4f65a0d4e openstf/stf:latest "stf triproxy dev --…" 4 hours ago Up About a minute 3000/tcp stf-poc_dev-triproxy_1_7224046ecd68
7465e46fd2a0 openstf/stf:latest "stf auth-mock --app…" 4 hours ago Up About a minute 3000/tcp `stf-poc_auth_1_f76f43d5e179
```

this is what happening with me, and i tried to restart and uninstall and reinstall, clear cash aand factory reset, it still showing this kind of ERROR, do you think i have to change the port of ADB from 5037 to 3000/tcp?

if yes how can i do that ?
THANKS !!

Just Restart Docker. It worked for me.

Just Restart Docker. It worked for me.

This worked for me too! For some reason it didn't work after I restarted the PC but did after I clicked "restart docker" in the icon tray.

Just Restart Docker. It worked for me.

This worked for me as well.

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

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.

Run the following command and get the container id that is using the port that you want to kill. Use the container id and remove it using the second command.

docker ps -a
docker rm container_id

Hi, I am running Docker (v 18.09.0) and getting the following error when starting sandbox-proxy. Please help.

C:Program FilesDockerDockerResourcesbindocker.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.

Hi, I am running Docker (v 18.09.0) and getting the following error when starting sandbox-proxy. Please help.

C:Program FilesDockerDockerResourcesbindocker.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.

restarting docker service helped me to resolve this issue.

version 18.09.0

Hi, I am running Docker (v 18.09.0) and getting the following error when starting sandbox-proxy. Please help.
C:Program FilesDockerDockerResourcesbindocker.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.

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.

Restart my docker in the windows 10, and then it works . ^^

Encountered the same problem. Restarting docker for windows helps.

If you are using Windows, run netstat -ab and check what is using port TCP 0.0.0.0:443, for me vmware was using it, even though I had exited it

Restart docker is not the best solution folk. (Also it's the first thing I've done)

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

Just restarted and it worked again

I have the same issue with 18.09.1 on Linux. Can this issue be reopened? Or otherwise an issue should be opened for a better error message indicating that this is not in fact a docker bug, which it appears to be.

If you continue to expect people to restart software at some point they will just rip out docker; it's not like there are no other container systems out there.

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

```Chain INPUT (policy DROP)
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.

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!

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! :)

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

Others above had mentioned netstat, and that is an excellent tool. An instance of nginx was running on port 80. I used netstat -ano | findstr :80 (cmd) or bash >> netstat -ano | grep :80, then killed the PID

https://stackoverflow.com/a/20724040/7954264

I solved it by updating windows build from 1803 to 1809

stop your docker daemon and start as an admin.

docker rm $(docker ps -a -q) did work for me.

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

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

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.

for me a manual restart of docker made it work

Same problem for me on Mac OS Mojave, trying to bring up mailu with docker-compose:

$ docker-compose -p mailu up -d
Creating network "mailu_default" with driver "bridge"
Creating mailu_fetchmail_1 ... 
Creating mailu_redis_1     ... 
Creating mailu_front_1     ... error
Creating mailu_fetchmail_1 ... done
Creating mailu_redis_1     ... done
ERROR: for mailu_front_1  Cannot start service front: driver failed programming external connectivity on endpoint mailu_front_1 (f7085e55644392e76cCreating mailu_antivirus_1 ... done
Creating mailu_admin_1     ... done

ERROR: for front  Cannot start service front: driver failed programming external connectivity on endpoint mailu_front_1 (f7085e55644392e76c6ae5cd6f3be159c58195e0fc85ae8610f2d84d42dbecab): Error starting userland proxy: port is not a proto:IP:port or unix:path: 'tcp:[:'
ERROR: Encountered errors while bringing up the project.
$

and the following:

  • Docker Desktop: 2.0.0.3
  • Engine: 18.09.2
  • Machine: 0.16.1
  • Notary: 0.6.1
  • Credential Helper: 0.6.0
  • Kubernetes: v1.10.11

I just restarted my Mac, and afterward ran

$ docker rm $(docker ps -a -q)

as someone recommended.

Here's the relevant stanza from docker-compose.yml for the "front" service:

  front:
    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}nginx:${MAILU_VERSION:-1.6}
    restart: always
    env_file: mailu.env
    logging:
      driver: json-file
    ports:
      - "127.0.0.1:80:80"
      - "::1:80:80"
      - "127.0.0.1:443:443"
      - "::1:443:443"
      - "127.0.0.1:25:25"
      - "::1:25:25"
      - "127.0.0.1:465:465"
      - "::1:465:465"
      - "127.0.0.1:587:587"
      - "::1:587:587"
      - "127.0.0.1:110:110"
      - "::1:110:110"
      - "127.0.0.1:995:995"
      - "::1:995:995"
      - "127.0.0.1:143:143"
      - "::1:143:143"
      - "127.0.0.1:993:993"
      - "::1:993:993"
    volumes:
      - "/Users/rmfuhrer/mailu/certs:/certs"
      - "/Users/rmfuhrer/mailu/overrides/nginx:/overrides"

AFAICT, I've got nothing listening on any of the ports mentioned in the docker-compose config:

$ netstat -a -f inet -p tcp -n | grep LISTEN
tcp4       0      0  *.17500                *.*                    LISTEN     
tcp4       0      0  127.0.0.1.17603        *.*                    LISTEN     
tcp4       0      0  127.0.0.1.17600        *.*                    LISTEN     
tcp4       0      0  *.49178                *.*                    LISTEN     
tcp4       0      0  127.0.0.1.6670         *.*                    LISTEN     
tcp4       0      0  127.0.0.1.8888         *.*                    LISTEN     
tcp4       0      0  *.88                   *.*                    LISTEN     
tcp4       0      0  *.445                  *.*                    LISTEN     
tcp4       0      0  *.22                   *.*                    LISTEN     
$

for me a manual restart of docker made it work

I can confirm that as well.

We are getting same issue on windows 10. Restart seems to be solving the problem but we have to restart it few time in a week. Is there a fix coming for this?

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

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..

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

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"

Restart docker works for me

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

I am having the same issue and yes restarting solved my issue. I hope they fix this.

Restart Docker...just that

Restart docker on windows also work for me :/

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.

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

As @AarashFarahani said. I stopped IIS, which I didn't need for this project, and the error went away.

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

docker rm $(docker ps -a -q) did work for me.

Didn't work for me (Windows 10, Docker version 18.09.2)

➜ sudo netstat -nlp | grep 443
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 501/vmware-hostd tcp6 0 0 :::443 :::* LISTEN 501/vmware-hostd

Problem solved

just restart docker and do deploy again -> works for me

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

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"

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

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

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

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

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

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.

for me a manual restart of docker made it work

I can confirm that as well.

Yup on Win10 this does the trick

@dtekchandani

Solution: Simply disable "Start Docker Desktop when you log in".
But keep it at start-up program (e.g. copy a link to docker into your startup folder here:
%USERPROFILE%AppDataRoamingMicrosoftWindowsStart MenuProgramsStartup

This will make Docker start later after logging in and that works for many people.

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

Having the same issue here, however restarting Docker/Windows/Hyper-V all result in failure.
Here is the printout I get from my run script.
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint pihole (c3b944c90dc0b7d948c3dd833becc51b754174a56c36272cda325611d9b792f5): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
Diag ID:
5C4CFABD-4AEA-4F67-9016-E9B6D58A3934/20190918072240
Initial Run Script: (if it even helps)
docker run -d --name pihole -p 53:53/tcp -p 53:53/udp -p 67:67/udp -p 80:80 -p 443:443 -v "${DOCKER_CONFIGS}/pihole/:/etc/pihole/" -v "${DOCKER_CONFIGS}/dnsmasq.d/:/etc/dnsmasq.d/" -e ServerIP="${IP}" --restart=unless-stopped --cap-add=NET_ADMIN --dns=127.0.0.1 --dns=1.1.1.1 pihole/pihole:latest
To attempt to restart the container, I am simply using
docker start pihole
The print seems to indicate it's a permissions error, so I tried running both Docker Desktop _and_ Powershell with elevated permissions, but I am still getting the same error. and when I say same, I mean it is verbatim each time.

For those on mac, try this command to see processes and stop them (the other commands didnt work for me):

sudo lsof -iTCP -sTCP:LISTEN -n -P

Rebooting Windows helped me.
Docker 2.1.0.3.38240

Restarting docker on MAC OS X MOJAVE doesn't fix this issue for me.
I'm trying to expose multiple ports, i.e. 5066, 5086, 8021, and some others.

Running with sudo works for me.

My problem was with 5000 port

$ docker ps

CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS              PORTS                    NAMES
d21a21826483        web                        "watchexec --restart…"   3 weeks ago         Up 28 hours         0.0.0.0:5000->5000/tcp   web_1

Then after stoping the container with 5000 ports, it helped me.

$ docker stop d21a21826483

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.

I had the same problem and tried the above but none worked for me.
What it does worked was restarting Windows.

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...

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

Restart Docker...just that

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

What worked for me was resetting docker desktop to factory values.

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

3 years and this bug is still alive and well...

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

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

Windows 10:
docker ps -a
docker rm $(docker ps -a -q)
docker-compose up

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

This worked for me:

cd /usr/libexec/docker/
ln -s docker-proxy-current docker-proxy
service docker restart

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

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

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.

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

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

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

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 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 :/

Try with LoiCha's solution. It's the only workaround that actually worked for me.

Just a heads up, I had this problem with Amazon ECS (EC2 mode), when trying to launch a new Task Definition. Turns out something else was already listening on that port in the EC2 host. I stopped the process and the task definition was able to start normally.

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

@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.

@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. 👍

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

and sudo service {nameOfService} stop

I've encountered same behavior, but for overriding of the service, by creating the docker-compose.override.yml. The files used:

docker-compose.yml:

version: '3.2'
services:
  app:
    build:
      context: ./
    ports:
     - "8000:80"
    volumes:
     - ./:/app

docker-compose.overrride.yml:

version: '3.2'
services:
  app:
    ports:
     - "8001:80"

That gives me following UNEXPECTED error:

ERROR: for my_app_1  Cannot start service app: driver failed programming external connectivity on endpoint my_app_1 (9235372fe636fba32be67f9f101a3432139c691a41fc6d207e53c98e25139a29): Bind for 0.0.0.0:8000 failed: port is already allocated

ERROR: for app  Cannot start service app: driver failed programming external connectivity on endpoint my_app_1 (9235372fe636fba32be67f9f101a3432139c691a41fc6d207e53c98e25139a29): Bind for 0.0.0.0:8000 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

I expected that ports directive in docker-compose.override.yml will override same in the docker-compose.yml (the 8000 port on my machine is already allocated by another application, that's why I tried the overriding) but this does not happen, which is wrong and seems like a bug.

OS: Windows 10
Docker: 19.03.12, build 48a66213fe

In my case the issue was due to running consul locally but also in a container.

For me it was firewall related, on CentOS 7, run your docker normally when working, then stop firewalld or just restart it, now try to restart that docker container, fails with this error. Restart docker service and try again... works fine.

I've encountered same behavior.
This solved my issue on centos7:
ps -ef | grep docker
kill the "...dockerd -H fd:// --containerd=/run/containerd/containerd.sock" process

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

Was this page helpful?
5 / 5 - 1 ratings

Related issues

dimsav picture dimsav  ·  3Comments

dazorni picture dazorni  ·  3Comments

darkrasid picture darkrasid  ·  3Comments

DhairyashilBhosale picture DhairyashilBhosale  ·  3Comments

saulshanabrook picture saulshanabrook  ·  3Comments