Cannot swarm init: cannot assign requested address

Expected behavior

$ docker swarm init --listen-addr
Swarm initialized …

Actual behavior

$ docker swarm init --listen-addr
Error response from daemon: listen tcp bind: cannot assign requested address


Attempting to follow the swarm tutorial.

Diagnostic ID: 4DA8D1D8-B659-4C77-B6E0-7CF74540D35F

Docker for Mac: version: mac-v1.12.0-beta16.2
OS X: version 10.10.5 (build: 14F1808)
logs: /tmp/20160624-162929.tar.gz
failure: No error was detected
[OK] docker-cli
[OK] app
[OK] menubar
[OK] virtualization
[OK] system
[OK] osxfs
[OK] db
[OK] slirp
[OK] moby-console
[OK] logs
[OK] vmnetd
[OK] env
[OK] moby
[OK] driver.amd64-linux

Port 2377 is available. The address is my local ethernet card address.
ether 38:c9:86:2f:f8:8f
inet6 fe80::3ac9:86ff:fe2f:f88f%en3 prefixlen 64 scopeid 0x9
inet netmask 0xffffff00 broadcast
nd6 options=1
media: autoselect (1000baseT <full-duplex,flow-control,energy-efficient-ethernet>)
status: active

Steps to reproduce the behavior

As above, simply run the command.

I also tried this on another of my Mac machines, with the same result.

Does your use-case actually require a custom listen address? docker swarm init should work just fine.

The native Docker for Mac is not actually a native app that runs on your host’s kernel, to know about your network.

The Docker engine is running in an Alpine Linux distribution on top of an xhyve Virtual Machine on Mac OS X or on a Hyper-V VM on Windows, and that VM is managed by the Docker application.

You basically provide docker with a host interface which from its perspective doesn’t exist.

The docker command runs natively on the mac, it should be able to see the network. The docker command may start things inside a container, but the docker command itself is not in a container, so it should be able to see my network and do the needful things. This is one of the things the new docker for mac should solve, should it not?

The docker command runs natively on the mac

This is a very true statement.

What you run on your Mac is actually just a docker client command, which, indeed, is native.

On the other hand the actual Docker Engine daemon, which receives commands from the docker client, runs on linux kernel inside a VM on Mac. See the quote from my previous message. That’s actually taken out of the release message.

Just run docker info on your Mac and see the “Operating System” section.

Here’s a good example that you can try yourself:

  • Run ifconfig on you Mac
  • Run ubuntu container with --net=host, which would expose the host’s networking stack inside a container
  • Run ifconfig inside container

What you’ll see is two different sets of interfaces.

There is no such thing as native Docker Engine. Docker Engine only runs on linux kernel. So, unless you are on Linux host, you will have this issue.

1 Like

I’m having this same basic issue. My iMac has the IP address and if I …

docker swarm init --listen-addr
No --secret provided. Generated random secret:

Error response from daemon: listen tcp bind: cannot assign requested address

One of the responses above suggests running init without listen-addr which gives …

docker swarm init
No --secret provided. Generated random secret:

Swarm initialized: current node (76hub80cls66ad1piyqj2quin) is now a manager.

To add a worker to this swarm, run the following command:
docker swarm join --secret eufek6klwo61assrbsht8d8rw
–ca-hash sha256:0d20ace10223db92413d8199b36d488475b7bf9ca0d60303433c4272bb6b055d

The problem is that it is using the IP address which is not reachable from another machine (my laptop).

I am also facing the same issue. When I try to use my mac ip address as listen address. I am getting error ‘bind: cannot assign requested address’

My Docker version :
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:51:55 2017
OS/Arch: linux/amd64
Experimental: true