docker swarm列出服务的依赖关系 [英] 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:
当我运行 docker服务检查mystack_web
生成的输出未显示对 depends_on 条目的任何引用。
When I run docker service inspect mystack_web
the output generated does not show any reference to the depends_on entry.
好的?以及如何打印给定docker服务的依赖项?
Is that okay? and how can I print the dependencies of a given docker service?
推荐答案
depends_on
未在docker swarm上使用:
The depends_on
isn't used on docker swarm:
depends_on
选项为在群集模式下使用版本3的组合文件部署堆栈时,将忽略此命令。 - 来自docker文档
The
depends_on
option is ignored when deploying a stack in swarm mode with a version 3 compose file. - from docker docs
在GitHub上的另一个很好的解释:
Another good explanation on GitHub:
<$ c $与
docker stack deploy
一起使用时,c> depends_on 是无操作的。群集模式服务在失败时会重新启动,因此没有理由延迟启动。即使它们几次失败,它们最终也会恢复。 - 来自GitHub
depends_on
is a no-op when used withdocker 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
这篇关于docker swarm列出服务的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!