dockerdocker-swarmdocker-exec

Access container from service on other node in Docker Swarm


I have Docker running in swarm mode, and created a service that runs one container. The service my-service runs on node1 (Manager node), and the container my-container is spawned on node2

From node1, how can I make a docker exec on the my-container running on node2 ?


Solution

  • I found this project, skopos-plugin-swarm-exec, that solves my issue.

    It can be used like this:

    docker run -v /var/run/docker.sock:/var/run/docker.sock datagridsys/skopos-plugin-swarm-exec task-exec --image <task id> <command>
    

    How It Works (Internals)
    Starting from a task ID and a command to execute, here are the steps that are taken: