A small convenience command to interactively deal with containers running remotely.
Project description
An interactive shell for remotely connecting to docker containers over SSH.
This was primarily built to help when dealing with the names given to containers in ECS, but can be used anywhere.
Installation
$ pip install ssh-docker
Usage
$ ssh-docker <hostname>
This will open up an interactive shell (similar to how Supervisor works) allowing you to directly query / perform actions on the containers within the host.
You can then list all containers running on the host via the following:
> list
Connecting to a container is as simple as using the connect command.
> connect
This will list out all of the available containers on the host, which you can then choose to connect to a specific one by entering the number of the container.
If you already know the name of the container you can also specify that in the command.
> connect name_of_container
By default it will attempt to run the bash shell when connecting, you can change this on a per run basis (or globally via the SSH_DOCKER_SHELL environment variable) if required:
> connect name_of_container /bin/ash
Connecting to a container will also print out the ssh command required to connect so you can share it with people who are not running ssh-docker.
Running arbitrary docker commands
You may want to run any of the available Docker commands on the server you’re connected to. You can do this via the docker command:
> docker [command]
Additional Tips
Hostname autocompletion
If the first attempt to connect to a hostname fails, it will attempt to find similar hostnames from your ssh config and suggest them to you.
Autocomplete
If you’d like to enable autocomplete in ZSH, you can add the following to your ~/.zshrc file:
eval "$(_SSH_DOCKER_COMPLETE=source_zsh ssh-docker)"
By entering ssh-docker [TAB] you will be able to cycle through all hostnames in your SSH config file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ssh-docker-1.2.2.tar.gz
.
File metadata
- Download URL: ssh-docker-1.2.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 148b0fcc4e8be7f01ad08461c3c93cae09bb1700bb7ac621ffcddc999bc09546 |
|
MD5 | 103e600bd0dc06b5d70876208859c97f |
|
BLAKE2b-256 | e847dcbf40062f283db7cc8b4e15cb3ce4865eebe81d6c660ddbd244baad2e0b |
File details
Details for the file ssh_docker-1.2.2-py3-none-any.whl
.
File metadata
- Download URL: ssh_docker-1.2.2-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2005fca827a698dcf2299e981897e4660e6f5482907bcf7bdcbc3f441f2944f |
|
MD5 | a102b7b476b153283a8b99711d6b804c |
|
BLAKE2b-256 | e182588a1b8ce928c5900ed60d9b8b53624a10b48a9225e7d7b50dee22e6cc91 |