Macvlan assign vlan id and ip address
ercanilbars opened this issue · 2 comments
ercanilbars commented
Hi its possible to assign vlan id and static ip address?
Like This
version: "3.7"
services:
access-server:
deploy:
labels:
ai.ix.auto-update: 'true'
image: registry.gitlab.com/ix.ai/swarm-launcher:latest
networks:
- guest-networks
- e-wifigate-networks
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:rw'
environment:
LAUNCH_IMAGE: e-access-controller:latest
LAUNCH_PULL: 'false'
LAUNCH_HOST_NETWORK: 'false'
LAUNCH_PROJECT_NAME: 'access-server'
LAUNCH_SERVICE_NAME: 'access-server'
LAUNCH_CAP_ADD: 'NET_ADMIN'
LAUNCH_PRIVILEGED: 'true'
LAUNCH_ENVIRONMENTS: 'VLAN=100'
LAUNCH_VOLUMES: '/var/docker/access-server:/etc/access-server:rw'
ports:
- 3990:3990
- 4990:4990
- 1645:1645
networks:
guest-networks:
driver: macvlan
attachable: true
driver_opts:
parent: ${GUEST_NETWORK_PARENT_ID}
ipam:
config:
- subnet: 192.168.182.0/24
e-local-networks:
driver: overlay
attachable: true
driver_opts:
parent: enp7s0
tlex commented
Thanks for the question.
A few comments on your stack file:
- the ports you expose have no impact on the
e-access-controller:latest
container - take a look atLAUNCH_PORTS
instead - a static IP is supported with
LAUNCH_EXT_NETWORKS_IPV4
only - I have no experience with macvlan, however, in order to use the network
guest-networks
in the container started by docker swarm, it must be defined inLAUNCH_EXT_NETWORKS_IPV4
orLAUNCH_EXT_NETWORKS
- make sure you look at the format, since you will need to prepend the name of the stack as well (see docs/networking.md for examples withLAUNCH_EXT_NETWORKS
)
While I don't actually use VLAN ID together with docker networks, I seem to remember that the VLAN ID is set as a sub-interface number. In your case, it would be then ${GUEST_NETWORK_PARENT_ID}.100
(see here a good explanation on that).
TL; DR:
Assuming your stack will be named foobar
, I suggest trying something like this:
version: "3.7"
services:
access-server:
deploy:
labels:
ai.ix.auto-update: 'true'
image: registry.gitlab.com/ix.ai/swarm-launcher:latest
networks:
- guest-networks
- e-wifigate-networks
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:rw'
environment:
LAUNCH_IMAGE: e-access-controller:latest
LAUNCH_PULL: 'false'
LAUNCH_HOST_NETWORK: 'false'
LAUNCH_PROJECT_NAME: 'access-server'
LAUNCH_SERVICE_NAME: 'access-server'
LAUNCH_CAP_ADD: 'NET_ADMIN'
LAUNCH_PRIVILEGED: 'true'
LAUNCH_ENVIRONMENTS: 'VLAN=100'
LAUNCH_VOLUMES: '/var/docker/access-server:/etc/access-server:rw'
LAUNCH_PORTS: '3990:3990 4990:4990 1645:1645'
LAUNCH_EXT_NETWORKS: "foobar_e-local-networks"
LAUNCH_EXT_NETWORKS_IPV4: "foobar_guest-networks:192.168.182.14"
networks:
guest-networks:
driver: macvlan
attachable: true
driver_opts:
parent: ${GUEST_NETWORK_PARENT_ID}.100
ipam:
config:
- subnet: 192.168.182.0/24
e-local-networks:
driver: overlay
attachable: true
driver_opts:
parent: enp7s0
Good luck!
tlex commented
Considering this issue has not been updated in so many months, I'm closing it now.