According to the compose file docs, this fragment should create a swarm service whose instances are connected to the host`s network:
services:
web:
...
networks:
hostnet: {}
networks:
hostnet:
external:
name: host
This used to work for me up to Docker 18.01.0-ce:
user@docker4:~$ cat hostnet.yml
version: '3.4'
services:
web:
image: nginx
networks:
hostnet: {}
networks:
hostnet:
external:
name: host
user@docker4:~$ docker stack deploy -c hostnet.yml hostnet
Creating service hostnet_web
user@docker4:~$ docker service ps hostnet_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
ekh2x9fiftwn hostnet_web.1 nginx:latest docker4 Running Running 10 seconds ago
WIth Docker 18.02.0, deployment fails with only one instance of "host" network is allowed":
user@docker4:~$ docker stack deploy -c hostnet.yml hostnet
Creating service hostnet_web
user@docker4:~$ docker service ps hostnet_web
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
tbrwxomncmxh hostnet_web.1 nginx:latest docker4 Ready Rejected 2 seconds ago "only one instance of "host" n…"
5wfft46phw7n \_ hostnet_web.1 nginx:latest docker4 Shutdown Rejected 7 seconds ago "only one instance of "host" n…"
o95qdlf4w029 \_ hostnet_web.1 nginx:latest docker4 Shutdown Rejected 8 seconds ago "only one instance of "host" n…"
Log output:
ERRO[2018-02-08T15:46:59.635485455+01:00] fatal task error error="only one instance of \"host\" network is allowed" module=node/agent/taskmanager node.id=[...] task.id=[...]
Output of `docker version`
Client:
Version: 18.02.0-ce
API version: 1.36
Go version: go1.9.3
Git commit: fc4de44
Built: Wed Feb 7 21:16:33 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.02.0-ce
API version: 1.36 (minimum version 1.12)
Go version: go1.9.3
Git commit: fc4de44
Built: Wed Feb 7 21:15:05 2018
OS/Arch: linux/amd64
Experimental: false
Output of `docker info`
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 133
Server Version: 18.02.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 222
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: 5tgj049z74d8bigq4osjujr1b
Is Manager: true
ClusterID: oy18buvxbbqb00libidep5kx9
Managers: 1
Nodes: 1
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 10.0.1.51
Manager Addresses:
10.0.1.51:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9b55aab90508bd389d7654c4baf173a981477d55
runc version: 9f9c96235cc97674e935002fc3d78361b696a69e
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-112-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 11.72GiB
Name: docker4
ID: BHDU:YEDX:7NMN:QIHK:PFXZ:MWOX:5WZF:FZTK:3RDE:GAEY:U7L2:NP72
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details (AWS, VirtualBox, physical, etc.):
Both command sequences were issued on the same box, a Ubuntu 16.04 LTS running on VMware workstation. Same behaviour on a three-node swarm cluster.
According to the compose file docs, this fragment should create a swarm service whose instances are connected to the host`s network:
This used to work for me up to Docker 18.01.0-ce:
WIth Docker 18.02.0, deployment fails with only one instance of "host" network is allowed":
Log output:
Output of `docker version`
Output of `docker info`
Additional environment details (AWS, VirtualBox, physical, etc.):
Both command sequences were issued on the same box, a Ubuntu 16.04 LTS running on VMware workstation. Same behaviour on a three-node swarm cluster.