From this PR that got recently merged into docker's 17.06 release candidate, we now have support for host networking with swarm services. However, trying out a very similar command I'm seeing an error:
$ docker service create --name nginx-host --network host nginx
Error response from daemon: could not find the corresponding predefined swarm network: network host not found
I'm running the 17.06 release candidate:
$ docker version
Client:
Version: 17.06.0-ce-rc2
API version: 1.30
Go version: go1.8.3
Git commit: 402dd4a
Built: Wed Jun 7 10:07:14 2017
OS/Arch: linux/amd64
Server:
Version: 17.06.0-ce-rc2
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 402dd4a
Built: Wed Jun 7 10:06:06 2017
OS/Arch: linux/amd64
Experimental: true
What's different from my command from what docker now supports?
After discussing with the docker devs, this feature needs swarm to be initialized after the upgrade to 17.06. Host and bridge networks created before the swarm init runs cannot be used with the node-local networks. Since this was a test environment, recreated my swarm with:
Now the
docker service create
command works:To verify, lets check the network interfaces inside the container: