Search code examples
dockerdocker-machine

How do I check that a docker host is in swarm mode?


After executing this;

eval $(docker-machine env mymachine)

How do I check if the docker daemon on mymachine is a swarm manager?


Solution

  • You could also use docker info to see the result of Swarm property (inactive or active).

    For example:

    function isSwarmNode(){
        if [ "$(docker info | grep Swarm | sed 's/Swarm: //g')" == "inactive" ]; then
            echo false;
        else
            echo true;
        fi
    }