我有一个由一个管理器和一个工作节点组成的docker swarm集群.然后我从笔记本电脑配置(tls和DOCKER_HOST)客户端以访问此群集.
当我运行docker ps时,我只看到来自worker节点的容器(而不是工作节点(!)的所有容器).
例如,来自我的客户:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a129d9402aeb progrium/consul "/bin/start -rejoi..." 2 weeks ago Up 22 hours IP:8300-8302->8300-8302/tcp,IP:8400->8400/tcp,IP:8301-8302->8301-8302/udp,53/tcp,53/udp,IP:8500->8500/tcp,IP:8600->8600/udp hadoop1103/consul-agt2-hadoop
我在工作节点运行docker ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4fec7fbf0b00 swarm "/swarm join --advert" 16 hours ago Up 16 hours 2375/tcp join
a129d9402aeb progrium/consul "/bin/start -rejoin -" 2 weeks ago Up 22 hours 0.0.0.0:8300-8302->8300-8302/tcp,0.0.0.0:8400->8400/tcp,0.0.0.0:8301-8302->8301-8302/udp,0.0.0.0:8500->8500/tcp,0.0.0.0:8600->8600/udp consul-agt2-hadoop
所以有两个问题:为什么docker ps不显示来自manager机器的容器而不是来自worker节点的所有容器?
最佳答案
默认情况下,经典swarm(作为容器运行)会隐藏来自docker ps输出的swarm管理容器.您可以使用docker ps -a命令显示这些容器.
这种行为可能会在其他地方记录,但我看到记录的行为的一个位置是在api differences docs:
GET “/containers/json”
Containers started from the swarm official image are hidden by default,use all=1 to display them.
all = 1 api语法相当于docker ps -a cli.