执行后;
eval $(docker-machine env mymachine)
如何检查mymachine上的docker守护进程是否是一个swarm管理器?
最佳答案
我目前没有方便的swarm节点,但看起来你可以简单地运行像docker node ls这样的东西.当定位不在swarm节点中的docker守护程序时,会导致:
Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.
$echo $?
1
所以测试看起来像:
if docker node ls > /dev/null 2>&1; then
echo this is a swarm node
else
echo this is a standalone node
fi