I’ve been banging my head over getting networking to work the way I want it to.
Situation:
- 2 physical interfaces
- ens160 10.10.0.13/24 => VLAN 10 on the router
- ens192 10.20.0.2/16 => VLAN 20 on the router
Goal:
Having several stacks with each container having their own static IP address and using the firewall for routing (no direct communication)
I have initialized the swarm with docker swarm init --advertise-addr=10.10.0.13
as this is the primary IP address to use.
Compose file:
version: '3.5'
services:
portainer:
image: portainer/portainer
deploy:
replicas: 1
update_config:
parallelism: 1
restart_policy:
condition: on-failure
command: --no-analytics
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /opt/data/portainer:/data
networks:
mgmt-vlan:
ipv4_address: 10.10.0.5
ports:
- 9000:9000
networks:
mgmt-vlan:
external: true
I have tried several commands to get the mgmt-vlan
network going (havent even started on the other network yet since this one doesn’t work…):
docker network create -d macvlan --subnet 10.10.0.0/24 --gateway 10.10.0.1 -o parent=ens160 --scope swarm mgmt-vlan
docker network inspect mgmt-vlan
[
{
"Name": "mgmt-vlan",
"Id": "mp33mlsa2d4ve83vhc4nd8r1z",
"Created": "2019-07-19T07:21:44.018736517Z",
"Scope": "swarm",
"Driver": "macvlan",
"EnableIPv6": false,
"IPAM": {
"Driver": "",
"Options": null,
"Config": []
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": null,
"Options": null,
"Labels": null
}
]
As you can see the IPAM part is empty
docker network create -d overlay --subnet=10.10.0.0/24 --gateway=10.10.0.1 --aux-address="exclude_host=10.10.0.13" -o parent=ens160 --scope swarm mgmt-vlan
docker network inspect mgmt-vlan
[
{
"Name": "mgmt-vlan",
"Id": "28w2wd4uclvm05th672jh7zo1",
"Created": "2019-07-19T07:22:17.536742512Z",
"Scope": "swarm",
"Driver": "overlay",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "10.10.0.0/24",
"Gateway": "10.10.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": null,
"Options": {
"com.docker.network.driver.overlay.vxlanid_list": "4099",
"parent": "ens160"
},
"Labels": null
}
]
docker stack deploy -c docker-core.yml core
docker inspect a9067438d42e
...
"Networks": {
"ingress": {
"IPAMConfig": {
"IPv4Address": "10.255.0.71"
},
"Links": null,
"Aliases": [
"a9067438d42e"
],
"NetworkID": "fwchqo21sxv8oey03zpl6wihb",
"EndpointID": "5bc9f00788b501d7ffe1cdb41cc7f4d13d392bc2ad9270e6e684dfb167232cfa",
"Gateway": "",
"IPAddress": "10.255.0.71",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:0a:ff:00:47",
"DriverOpts": null
},
"mgmt-vlan": {
"IPAMConfig": {
"IPv4Address": "10.10.0.3"
},
"Links": null,
"Aliases": [
"a9067438d42e"
],
"NetworkID": "28w2wd4uclvm05th672jh7zo1",
"EndpointID": "7c328e1896e9c7b2d7d22b35b2bdc05621786df53ca62d420bf7f1d98f626360",
"Gateway": "",
"IPAddress": "10.10.0.3",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:0a:32:00:03",
"DriverOpts": null
}
}
...
This one does not take its assigned IP and neither of them is pingable/reachable.
Anyone have an idea what I’m missing?
Thanks!