I want to assign static ip to each service with macvlan network named “barkati” but when I deploy my docker-stack yml file using sudo docker stack deploy -c docker-stack9.yml ims i get this error:
network "barkati" is declared as external, but it is not in the right scope: "local" instead of "swarm"
Please share the output of docker network inspect barkati.
It seems like you created the network without the parameter -d overlay.
Note: if you want non-swarm container to be able to use the same network, you also need the parameter --attachable
Note2: last time I checked, swarm services have not been able to use ipv4_address, as this feature was not implemented for swarm services. I expect it to be the next error message, after you re-created your network as overlay network.
The error message doesn’t really make sense to me, unless one at least one of the nodes a preexisting network with the same name exists that is declared differently.
Update: I can see from the peer list that it’s a single node swarm cluster. So my idea of a preexisting network on one of the other nodes can’t be the issue if there are no other nodes…
I almost missed it, but the network should be defined this way:
networks:
default:
external: true
name: barkati
The old and deprecated or possibly removed way was:
networks:
default:
external:
name: barkati
But that used to give me a warning with recent compose versions. Let’s assume that the extra external: true was ignored and the old syntax still worked for you. Sometimes I override the default network too, but I have never done it with the overlay network, so if my previous suggestion doesn’t work, you could try to use a different name instead of default.
I just updated the code with the new network name, so it is still using the ipv4_address parameter that @meyay mentioned, but I am curious if it gives you the same error message.
Thankyou for your Answer.
with change my network setting on yml file solved my error but as yet, services don’t get static ip as defined on yml file .(for example scscf not get 192.168.2.16)