Skip to content

Commit 659bd77

Browse files
authored
Merge pull request #3 from ewdicus/elliott/first-release
Update Readme for first release
2 parents 9084144 + 0c5f229 commit 659bd77

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Docker-shell is a small utility to shell into a running Docker container by name or ID.
2+
3+
This uses Typer, which itself uses Click.
4+
5+
# Requirements
6+
7+
If you can use [pipx](https://github.com/pipxproject/pipx), then just that and it'll handle it. Otherwise, You'll need:
8+
9+
- Python 3.8+
10+
- Poetry
11+
12+
# Installation
13+
14+
You can either install directly from the release (using version 0.1.0 as an example) via:
15+
16+
```sh
17+
pipx install https://github.com/ewdicus/docker-shell/archive/docker_shell-0.1.0-py3-none-any.whl
18+
```
19+
20+
or, you can download the wheel from the releases and then follow step 4 below in [From source](#from-source).
21+
22+
## From source
23+
24+
This is still in development and I don't think building this and installing it yourself is bad. If you want to try that, the steps should be:
25+
26+
1. Clone this repo
27+
2. `poetry install`
28+
3. `poetry build`
29+
4. `pipx install <wherever this is>/docker_shell-0.1.0-py3-none-any.whl`
30+
31+
> Note: If you install via pip rather than pipx make sure to use `pip install --user ...` so this installs in your user's directory.
32+
33+
# Usage
34+
35+
If you just run `docker-shell` you'll get a nice little table of running containers:
36+
37+
```sh
38+
$ docker-shell
39+
40+
| ID | Name | Image Tags |
41+
|------------|-------------------|----------------------------|
42+
| d1e5dab390 | aminoweb_nginx_1 | ['aminoweb_nginx:latest'] |
43+
| c817abb130 | aminoweb_www_1 | ['aminoweb_www:latest'] |
44+
| 1020d0c04f | aminoweb_www_js_1 | ['aminoweb_www_js:latest'] |
45+
```
46+
47+
If you type `docker-shell` and then hit tab, it should autocomplete running container names:
48+
49+
```sh
50+
$ docker-shell aminoweb_
51+
aminoweb_nginx_1 aminoweb_www_1 aminoweb_www_js_1
52+
```
53+
54+
Running `docker-shell` with either a container name or ID will open a bash shell into that container (with a fallback to sh).
55+
56+
```sh
57+
$ docker-shell aminoweb_www_1
58+
amino@c817abb1309e:/data/app$
59+
```
60+
61+
> Note: You can customize the command that's executed on the running container with the -c/--command option, or by setting a `DOCKER_SHELL_COMMAND` env var.
62+
63+
And just for the sake of being complete here's the help:
64+
65+
```sh
66+
$ docker-shell --help
67+
Usage: docker-shell [OPTIONS] [CONTAINER]
68+
69+
Shell into a running Docker container by name or ID.
70+
71+
If run with no arguments, will display running containers. Change the
72+
shell command with --command, -c, or by setting an env var called
73+
DOCKER_SHELL_COMMAND.
74+
75+
Arguments:
76+
[CONTAINER] This can be a container name or ID.
77+
78+
Options:
79+
-c, --command TEXT The shell command to run in the container. [env var:
80+
DOCKER_SHELL_COMMAND; default: /bin/sh -c "[ -e
81+
/bin/bash ] && /bin/bash || /bin/sh"]
82+
83+
--install-completion Install completion for the current shell.
84+
--show-completion Show completion for the current shell, to copy it or
85+
customize the installation.
86+
87+
--help Show this message and exit.
88+
```

0 commit comments

Comments
 (0)