for-mac icon indicating copy to clipboard operation
for-mac copied to clipboard

Cannot bind to specific IPs: cannot assign requested address.

Open tecnobrat opened this issue 6 years ago • 46 comments

  • [x] I have tried with the latest version of my channel (Stable or Edge)
  • [x] I have uploaded Diagnostics
  • Diagnostics ID: D101B22D-FABF-4C6B-A4D9-07BA9A23270D/20200121200047

Expected behavior

I should be able to bind to any IP on my mac.

Actual behavior

Trying to bind explicitly to my mac's wifi address results in an error: 192.168.2.2:443: bind: cannot assign requested address.

Binding to 127.0.0.1 or 0.0.0.0 explicitly does work, any other IP does not work.

Information

  • macOS Version: 10.15.2 (19C57)
  • Docker for Mac: 2.2.0.0 (42247)

Steps to reproduce the behavior

  1. Use ifconfig to find your wifi or lan IP.
  2. Run docker run -p 192.168.2.2:443:443 nginx
  3. Receive this error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint elated_austin (f94e21669eb9ad9b6cc3d9cc4effd5beb78617d558c0213c2a3c72da10fbfbb0): Error starting userland proxy: listen tcp 192.168.2.2:443: bind: cannot assign requested address.

This error only started when upgrading to 2.2.0.0. Downgrading to 2.1.0.4 and the problem goes away.

tecnobrat avatar Jan 21 '20 20:01 tecnobrat

I'll confirm this. It seems that binding to an IP directly fails.

arlaneenalra avatar Jan 21 '20 21:01 arlaneenalra

Binding to 127.0.0.1 directly does work though, so its odd.

tecnobrat avatar Jan 21 '20 21:01 tecnobrat

I am also affected by this error. I was using an alias to bind the ports, so that it wouldn't conflict with other services running on the same ports.

To create an alias I use:

sudo ifconfig lo0 alias 10.10.10.10

And this docker-compose.yml used to work:

version: '3.7'

services:
  nginx:
    image: nginx:latest
    ports:
      - 10.10.10.10:80:80

thiagorb avatar Jan 22 '20 06:01 thiagorb

I was using an alias to bind the ports, so that it wouldn't conflict with other services running on the same ports.

Same motivation and confirming the same issue on 2.2.0.0.

This seems to be a recurring problem. Previous reports: https://github.com/docker/for-mac/issues/4032, https://github.com/docker/for-mac/issues/3970

lmakarov avatar Jan 22 '20 07:01 lmakarov

Downgrading to v2.1.0 solves the issue for me: https://download.docker.com/mac/stable/40693/Docker.dmg

raido avatar Jan 22 '20 09:01 raido

Confirmed this issue applies to both Mac and Windows Docker Desktop versions.

Downgrading to the latest 2.1.x version (2.1.0.5) solves the problem. Here are the direct download links:

  • Mac: https://download.docker.com/mac/stable/40693/Docker.dmg
  • Windows: https://download.docker.com/win/stable/40693/Docker%20Desktop%20Installer.exe

lmakarov avatar Jan 24 '20 17:01 lmakarov

I hit this today as well. Downgrade I go...

jaredkipe avatar Jan 27 '20 15:01 jaredkipe

Any status on a fix for this issue?

esteinborn avatar Feb 05 '20 12:02 esteinborn

I've downgraded, which resolves it, following.

ryanissamson avatar Feb 06 '20 19:02 ryanissamson

Here is the issue on the Windows side: https://github.com/docker/for-win/issues/5546

tekNorah avatar Feb 06 '20 20:02 tekNorah

Also experiencing this issue on Docker for Mac: 2.2.0.3

danshumaker avatar Feb 11 '20 16:02 danshumaker

I also hit this. My specific IP in question is bound to lo0 interface on Mac.

alvarow avatar Feb 13 '20 19:02 alvarow

so will this be fixed soon?

leirissa avatar Feb 20 '20 10:02 leirissa

Interestingly it does work when the IP you're attempting to bind to is added to the lo interface inside the docker virtual machine as well:

docker run -it --rm --privileged --pid=host justincormack/nsenter1
ip addr add 10.10.10.10/32 dev lo

Then add it locally (on MacOS):

sudo ifconfig lo0 alias 10.10.10.10/32

And run some service on it:

docker run -p 10.10.10.10:80:80 nginx

10.10.10.10:80 is then properly forwarded to the container. This does, however, break connectivity from containers to that specific IP.

friek avatar Feb 20 '20 13:02 friek

Also experiencing this issue on Docker for Mac: 2.2.0.4

handelaar2 avatar Mar 13 '20 11:03 handelaar2

@friek alias is not working for me!

FernandoMiguel avatar Mar 16 '20 18:03 FernandoMiguel

I can confirm I am experiencing the same issue with 2.2.0.4 on Mojave 10.14.6: unable to bind to a port when specifying an IP address.

I use this because I want a container only to be listening on a specific VLAN on my machine.

With 2.1.0.5 all is working as expected, so I too reverted to that version.

hollie avatar Mar 17 '20 21:03 hollie

Tried 2.2.0.4 again on my local. The new GUI features promised were too tempting not to try again. Bummed like everyone else0. Sadly returning to 2.1.0.5.

$ fin project start
 ALERT:  Some Docksal services were not running
         Restarting Docksal system services...
Configuring network settings...
Configuring NFS shares...
NFS shares are already configured
Resetting Docksal system services...
 * proxy
docker: Error response from daemon: driver failed programming external connectivity on endpoint docksal-vhost-proxy (9443bb5547db8ef71b9fa8a29fb74483f0ce754a4e1941f21418c72e1dc7de22): Error starting userland proxy: listen tcp 192.168.64.100:443: bind: cannot assign requested address.
 ERROR:  Failed starting the proxy service.

kwiechmann avatar Mar 18 '20 12:03 kwiechmann

You know what would be great? If we could get any indication at all from the Docker team that they consider this issue a priority. This has evidently broken Docker completely for a lot of people.

MikkelPaulson avatar Mar 18 '20 21:03 MikkelPaulson

It sure did, we're starting to look for alternatives for our workflow since we'll have to change it, might as well see what's out there... Multirun seems instersting too.

alvarow avatar Mar 19 '20 14:03 alvarow