0

I have Docker swarm cluster with overlay network (name overlay-test) with single-manager and 2 worker nodes. One of worker node contains only database server container. When I deploy stack on cluster and my stack doesn't contains instructions to deploy db server service on worker node I have an issue with no network creation on node. My task is to connect db server container to this network manually. The only way I see to resolve this is to make this node with db server as swarm manager, but swarm manager should be only other host.

Any ideas in another ways to resolve? Thanks in advance.

Docker-compose for deploy:

version: "3.5"

services:

  test-front:
    build: ./host-front/test-front
    image: test-front:alpine-3
    depends_on:
      - test-back
    networks:
      - test-multihost
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodename == front

  test-back:
    build: ./host-front/test-back
    image: test-back:openjdk8-alpine
    restart: always
    networks:
      - test-multihost
    depends_on:
      - test-db
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodename == front

  test-adapter:
    build: ./host-front/test-adapter
    image: test-adapter:openjdk8-alpine
    restart: always
    networks:
      - test-multihost
    depends_on:
      - test-core
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodename == front

  test-core:
    build: ./host-main/test-core
    image: test-core:openjdk8-alpine
    restart: always
    depends_on:
      - test-db
    networks:
      - test-multihost
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodename == main

  test-db:
    build: ./host-main/test-db
    image: test-db:openjdk8-alpine
    restart: always
    depends_on:
      - test-postgres
    networks:
      - test-multihost
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodename == main

  test-postgres:
    build: ./host-db/test-postgres
    image: test-postgres:postgres-12.1-alpine
    restart: always
    networks:
      - test-multihost
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.labels.nodename == db

networks:
  test-multihost:
    external: true

I created overlay network manually: docker network create -d overlay --attachable test-multihost

  • It would be helpful if you provided your docker-compose.yml file; or, if you're using an imperative setup then the commands that you're using to create the services. – benbotto Feb 11 '20 at 17:10
  • It's not clear from your manifest file how you are creating the `overlay-test` network or, for that matter, how it even comes into the picture. `overlay-test` isn't present at all in the manifest. – benbotto Feb 11 '20 at 17:56
  • As a side note, `restart` is ignored in swarm mode: you probably should specify a `restart_policy`. `depends_on` is also ignored in swarm mode. – benbotto Feb 11 '20 at 17:58
  • @avejidah Thank you to side notes. I made changes. – Alexey Shcheglov Feb 11 '20 at 18:30
  • I created overlay network manually: docker network create -d overlay --attachable test-multihost – Alexey Shcheglov Feb 11 '20 at 20:33

1 Answers1

1

The network is to be created only on the Manager, they are seen by the workers only when there is a container using them.

Rif. : https://docker-docs.netlify.app/network/network-tutorial-overlay/#walkthrough

Inspect the nginx-net network on master, worker-1, and worker-2. Remember that you did not need to create it manually on worker-1 and worker-2 because Docker created it for you. The output will be long, but notice the Containers and Peers sections. Containers lists all service tasks (or standalone containers) connected to the overlay network from that host.