Docker Community Forums

Share and learn in the Docker community.

Why does docker stack deployment creates a new overlay but not join an existing overlay?

I initialized a docker swarm have have 3 nodes in it.
Then I add an overlay with

docker network create --driver overlay pica_net

and then I want to deploy the following service with 3 tasks

services:
  nacos:
    image: nacos:latest
    networks:
      pica_net:
    deploy:
      mode: replicated
      replicas: 3
    volumes:
      - /opt/logs/nacos:/app/logs
networks:
  pica_net:

I started it with

docker stack deploy -c docker-compose.yml nacos-stack

but I see the process is:

Creating network nacos-stack_pica_net
Creating service nacos-stack_nacos

I am wondering why doesn’t these three containers join the overlay network pica_net directly, instead docker creates a new overlay network nacos-stack_pica_net, what is wrong?

It works as designed. The network you declared in the compose.yml is not marked as external: true, thus it will create a private one.