Swarm and setting up Vlans

I am new to docker. I have setup a few standalone images but want to setup some a dns sever adguard on a redundant setup. I am running two raspery pi i have docker setup on both and swarm is running. I have one manager and a worker. I have able to get adguard up and running but it is only on the default vlan.
I am not sure how to get the service on correct wire.
Physical switch setup
Native not tagged 10.1.40.0/24
Addguard VLAN 172.16.5.0/24

This is my compose file I used the cmd
sudo docker stack deploy --compose-file adguard.yml adguard

The error i get is
container_name: Setting the container name is not supported.

Creating network adguard_vlan_5
Creating service adguard_adguard
failed to create service adguard_adguard: Error response from daemon: The network adguard_vlan_5 cannot be used with services. Only networks scoped to the swarm can be used, such as those created with the overlay driver.

version: "3.6"

services:
  adguard:
    image: adguard/adguardhome:latest
    container_name: adguard
    networks:
         vlan_5:
             ipv4_address: 172.16.5.16
    ports:
      - 53:53/udp
      - 53:53/tcp
      - 67:67/udp
      - 68:68/udp
      - 80:80/tcp
      - 443:443/tcp
      - 443:443/udp
      - 3000:3003/tcp
      - 784:784/tcp
      - 853:853/udp
      - 8853:8852/udp
      - 5443:5443/tcp
      - 5443:5443/udp

networks:
    vlan_5:
        driver: macvlan
        driver_opts:
            parent: eth0.5
        ipam:
            driver: default
            config:
                - subnet: 172.16.5.0/24

A google search for “swarm macvlan setup” yielded following result:
https://collabnix.com/docker-17-06-swarm-mode-now-with-macvlan-support/

I used it in the path and it should be still valid with 20.10.x.

You first need to create a config-only network configuration on each node and then finaly create the macvlan network that uses these config-only network configurations to create a macvlan across all nodes.

But: as far as I remember “ipv4_address” is not a valid field for swarm deployments.

SO i followed he steps. But it doesn’t abide by the ip range . It assigns a random IP range.
What I am trying to do is the physical interface eth0 is on the management wire. I then want to tag vlan5 That should be for adguard.
All i am trying to do is if once raspberry pi does it should spin up a new service on the the other. But i need them on the 5 vlan.

This requires further explaination.

Like I wrote before: “ipv4_address" is not valid for swarm stack deployments. This is the case regardless whether you use an overlay, macvlan, ipvlan or whatever network. The suppport for “ipv4_address” was never implemented for swarm stack deployments. This is a docker-compose only feature (and docker run of course)

Creating macvlan networks that use vlan interfaces as macvlan parent interfaces is the only way I am aware of. Please let us know when you find a different solution.