Skip to content

neuroforgede/docker-swarm-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-swarm-proxy

What if you wanted a docker exec, but for Docker swarm?

A problem with Docker Swarm and automation with it has been that you can't directly exec into any service from the command line. There exist some workarounds to achieve this behaviour, but in the end you want something similar and as convenient as docker exec but for services.

grafik

Installation

Prerequisites

Install docker-py and click:

pip3 install docker
pip3 install click

Install the plugin your docker cli (from github)

rm ~/.docker/cli-plugins/docker-swarmproxy
curl -L https://raw.githubusercontent.com/neuroforgede/docker-swarm-proxy/master/docker_swarm_proxy.py -o ~/.docker/cli-plugins/docker-swarmproxy
chmod +x ~/.docker/cli-plugins/docker-swarmproxy

Or copy from a local copy of this repo:

cp docker_swarm_proxy.py ~/.docker/cli-plugins/docker-swarmproxy
chmod +x ~/.docker/cli-plugins/docker-swarmproxy

Usage

NOTE: For remote clusters, only usage of the DOCKER_HOST environment variable is supported. Usage of Docker Contexts for switching environments is not supported. For remote clusters we strongly advise against exposing the TCP socket directly. Instead use the SSH tunneling support of docker cli as described here.

Exec into a running service

docker swarmproxy service exec -it vibrant_bell bash

See all available options:

docker swarmproxy service exec --help

Use - in the command

Since swarmproxy uses click under the hood for argument parsing, you have to use -- before any exec command.

This will not work:

docker swarmproxy service exec -it vibrant_bell bash -c 'echo hello'

This will work:

docker swarmproxy service exec -it vibrant_bell -- bash -c 'echo hello'

About

What if you wanted a docker exec, but for Docker swarm? - Control any node in the swarm from your CLI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published