简体   繁体   中英

Docker compose is not finding network from swarm host

I have one server where I create an overlay network with the following command:

docker network create --driver=overlay --attachable caja_gestiones

In server two I want to use my docker compose to deploy all my containers and one of them use the gestiones network and the default network, this is my docker-compose.yml:

version: '3.3'
services:
  msgestiones:
    image: msgestiones:latest
    hostname: msgestiones
    container_name: msgestiones
    environment:
      - perfil=desarrollo
      - JAVA_OPTS=-Xmx512M -Xms512M
      - TZ=America/Mexico_City
    networks:
      - marcador
      - caja_gestiones
  msmovimientos:
    image: msmovimientos:latest
    hostname: msmovimientos
    container_name: msmovimientos
    environment:
      - perfil=desarrollo
      - JAVA_OPTS=-Xmx512M -Xms512M
      - TZ=America/Mexico_City
    networks:
      - marcador
networks:
  marcador:
    driver: bridge
  caja_gestiones:
    external:
      name: caja_gestiones

When I ran the docker compose it throws an error saying that the network does not exists, but if I run a dummy container using that network, the network appear and the compose works, how can I make the compose use the overlay network without run a dummy container before?

Did you try to deploy it as a stack instead of a compose? You can use the same compose file, but deploy it with docker stack deploy -c composefile.yaml yourstackname ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM