docker swarm list dependencies of a service

試著忘記壹切 提交于 2020-02-04 01:30:33

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/49283363/docker-swarm-list-dependencies-of-a-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!