# Docker stack deploy do not use networks

**URL:** <https://forums.docker.com/t/docker-stack-deploy-do-not-use-networks/142571>\
**Category:** Swarm\
**Tags:** swarm, docker-compose\
**Created:** [July 19, 2024, 3:06pm UTC](https://forums.docker.com/t/docker-stack-deploy-do-not-use-networks/142571 "2024-07-19T15:06:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![antoniolobefaro](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@antoniolobefaro](https://forums.docker.com/u/antoniolobefaro)\
**Post date:** [July 19, 2024, 3:06pm UTC](https://forums.docker.com/t/docker-stack-deploy-do-not-use-networks/142571/1 "2024-07-19T15:06:26Z")

</div>

HI,

I’m having problem with network. In my swarm env I created a network

> docker network create -d overlay dls\_network

here is my compose

```auto
version: "3.8"
services:
  mysql:
    image: mysql:8.3.0
    ports:
      - "3306:3306"
    environment:
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
    networks:
      - dls_network
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
      interval: 30s
      timeout: 10s
      retries: 5

  keycloak:
    image: quay.io/keycloak/keycloak:24.0.3
    environment:
      - KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN}
      - KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD}
      - KC_DB=${KC_DB}
      - KC_DB_URL_HOST=${KC_DB_URL_HOST}
      - KC_DB_URL_DATABASE=${KC_DB_URL_DATABASE}
      - KC_DB_USERNAME=${KC_DB_USERNAME}
      - KC_DB_PASSWORD=${KC_DB_PASSWORD}
      - KC_HEALTH_ENABLED=${KC_HEALTH_ENABLED}
    ports:
      - "8080:8080"
    command: start-dev
    networks:
      - dls_network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health/ready"]
      interval: 30s
      timeout: 10s
      retries: 5

networks:
  dls_network:
    external: true

```

when I run

> docker stack deploy -c docker-compose.yml dls-sevices

if I inspect the network I see `Containers: Null` and keycloak doesn’t find mysql service.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/bluepuma77/32/32688_2.png) [@bluepuma77](https://forums.docker.com/u/bluepuma77)\
**Post date:** [July 20, 2024, 7:47pm UTC](https://forums.docker.com/t/docker-stack-deploy-do-not-use-networks/142571/2 "2024-07-20T19:47:16Z")

</div>

Have you tried to create the Docker network inside compose, maybe compare to [simple Traefik Swarm example](https://github.com/bluepuma77/traefik-best-practice/tree/main/docker-swarm-traefik).

Note that you are playing a dangerous game. You use Swarm, so I assume multiple nodes. You don’t persist your data in MySQL, so it will be gone when you re-create the container. But even volumes and bind-mounts are not shared across nodes. So if the container is re-scheduled to a different node, all data is gone.
