Search code examples
dockerdocker-swarmdocker-stack

docker swarm list dependencies of a service


Let's say we have the following stack file:

version: "3"
services:
  ubuntu:
    image: ubuntu
    deploy:
      replicas: 2
      restart_policy:
        condition: on-failure
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
    entrypoint:
      - tail
      - -f
      - /dev/null
    logging:
      driver: "json-file"
    ports:
      - "80:80"
    networks:
      - webnet
  web:
    image: httpd
    ports:
      - "8080:8080"
    hostname: "apache"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    deploy:
      placement:
        constraints: [node.role == manager]
      resources:
        limits:
          memory: 32M
        reservations:
          memory: 16M
    depends_on:
      - "ubuntu"
    networks:
      - webnet
networks:
  webnet:

When I run docker service inspect mystack_web the output generated does not show any reference to the depends_on entry.

Is that okay? and how can I print the dependencies of a given docker service?


Solution

  • The depends_on isn't used on docker swarm:

    The depends_on option is ignored when deploying a stack in swarm mode with a version 3 compose file. - from Docker Docs

    Another good explanation on GitHub:

    depends_on is a no-op when used with docker stack deploy. Swarm mode services are restarted when they fail, so there's no reason to delay their startup. Even if they fail a few times, they will eventually recover. - from GitHub