Container fails to start "Cannot assign requested address"

Expected behavior

Container starts.

Actual behavior

Container fails to start, the output is:

WARNING: Logging before InitGoogleLogging() is written to STDERR
F0416 02:44:14.481470     1 process.cpp:889] Failed to initialize: Failed to bind on 192.168.1.2:5050: Cannot assign requested address: Cannot assign requested address [99]
*** Check failure stack trace: ***

note No other process is operating on port 5050.

Information

OS X: version 10.11.3 (build: 15D21)
Docker.app: version v1.11.0-beta7
Running diagnostic tests:
[OK]      docker-cli
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
Docker logs are being collected into /tmp/20160415-223824.tar.gz
Most specific failure is: No error was detected
Your unique id is: D8776244-3D6F-4CC4-873E-F94A1C79E44C

Steps to reproduce the behavior

  1. Try to start the mesos-master docker image:
    hostIp=$(ipconfig getifaddr en0)
docker run \
-e MESOS_HOSTNAME=$hostIp \
-e MESOS_IP=$hostIp \
-e MESOS_QUORUM=1 \
-e MESOS_ZK=zk://$hostIp:2181/mesos \
--name mesos-master \
--net=host \
--restart always \
mesosphere/mesos-master:0.28.0-2.0.16.ubuntu1404

When using Docker Toolbox that same image would run just fine, the only exception was MESOS_HOSTNAME and MESOS_IP had to be set to the IP address of the VirtualBox VM (since I’m on a Mac).

I read some other posts talking about networking (with docker for mac beta) and discovered that I should be able to ping “docker.local” (the VM running docker?). Anyhow, I was getting “request timed out” errors so I rebooted my mac.

Once I logged back in I was able to ping docker.local. I updated my script so the “dockerIp” was set to the IP address returned when I pinged docker.local, and now it works!