A simple tool to execute a docker command in all the swarm nodes. It uses swarm's global service mode to execute the command in all the nodes and bind-mounts docker cli and docker socket.
./build.sh
- This needs to run on a swarm manager
- Docker 1.12 or higher needs to be running on all of the hosts on your swarm
Run the image passing in the different commands.
docker service create --mode=global --restart-condition none --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock mavenugo/swarm-exec:17.03.0-ce docker run --net=host busybox sleep 5000
or simply
./swarm-exec.sh docker run --net=host busybox sleep 5000
Also, checkout the convenience script swarm-exec.sh