A tool for executing commands in service containers deployed on Docker swarm - equivalent to:
docker service exec <task_id> <command> <args>
Docker Swarm does not yet provide a way to execute commands inside a service task from the manager node (CLI or API). This project provides an easy-to-use mechanism for doing just that: executing a command in the container of a service task.
Think of it as a docker service exec that applies to a specific task of a service.
The need for this project is expected to go away when the Support for executing into a task #1895 issue is resolved in the Docker swarm project and the same capability becomes available directly in the Docker swarm API and command-line client.
On the swarm manager node, run the following command:
docker run -v /var/run/docker.sock:/var/run/docker.sock
sjurkuhn/docker-swarm-exec \
task-exec <taskID> <command> [<arguments>...]
where:
<taskID> is the task ID of the task in which you want to execute a command (see task IDs with docker service ps <service_name>)<command> command to execute (e.g. curl)<arguments>... zero or more arguments to pass to the command (e.g., http://example.com/file)Note: it is possible to use the
swarm-execscript directly, if python3 and the docker Python SDK are installed. The container packaging is easier to use in most cases.
Starting from a task ID and a command to execute, here are the steps that are taken:
docker exec command using the node-local Docker engine APIThis is an open source project. See the LICENSE file.
If you want to propose an improvement, issues and pull requests are always welcome!
Content type
Image
Digest
Size
100.4 MB
Last updated
about 6 years ago
docker pull sjurkuhn/docker-swarm-exec