Skip to content

About

A tool built with Claude to manage the deletion of Docker images, which could evolve into something better

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

docker-tool

A menu-driven terminal (curses) tool for browsing Docker images, the containers created from them, and cleaning both up.

Setup

python3 -m venv .venv
.venv/bin/pip install -e '.[dev]'

Run

.venv/bin/docker-tool        # or: .venv/bin/python -m docker_tool

Install to ~/.local/bin (run from any directory)

Make sure ~/.local/bin is on your PATH. Most distros add it automatically once the directory exists. If not, add export PATH="$HOME/.local/bin:$PATH" to ~/.bashrc.

Option A: symlink the venv launcher (recommended while developing). The venv install is editable, so edits to the source take effect immediately:

mkdir -p ~/.local/bin
ln -sf "$PWD/.venv/bin/docker-tool" ~/.local/bin/docker-tool
docker-tool

The launcher's shebang points at this project's .venv, so keep the project directory in place. To uninstall, run rm ~/.local/bin/docker-tool.

Option B: standalone install with pipx. This makes an isolated copy that doesn't depend on this directory. Re-run it after changes:

sudo apt install pipx           # once
pipx install --force .          # installs ~/.local/bin/docker-tool
docker-tool

To uninstall, run pipx uninstall docker-tool.

(Plain pip install --user is blocked on Ubuntu/Debian by PEP 668, hence pipx.)

Keys

Key Lists Details view
Up/Down, j/k Move cursor (>) Scroll
PgUp/PgDn, g/G Page / jump to top or bottom Page / top / bottom
Space Toggle selection (*) Page down
a Select all / deselect all
Enter Open (only when nothing is selected) Back
D (uppercase) Delete the selected items, or the item under the cursor if none are selected, after a confirmation (d does nothing)
F2 Rename the image or container under the cursor (only when nothing is selected)
F5 Run: open an interactive session (see below; only when nothing is selected)
r Refresh from docker (normally not needed, see below) Refresh
q, Esc, Left Back (quits from the image list) Back

The screen refreshes by itself when images or containers change, whether the change comes from this tool, another terminal, a build or a container exiting. The tool follows docker events in the background and reloads the current screen shortly after a change, keeping the cursor and the selection. If the event stream stops (for example, the daemon was restarted), it is restarted every 10 seconds. Relative times such as "Up 5 minutes" only change on a refresh.

The delete confirmation defaults to No. Press y or pick Yes, delete to go ahead.

Docker has no rename command, so F2 runs docker image tag <id> <new> and then docker image rm <old>. Because the image keeps its new tag, the rm only untags the old one. An untagged (<none>) image just gets tagged. If the new name already belongs to another image, you are asked before the name is moved. Containers are renamed with docker container rename. Docker itself refuses a name that is already in use.

Interactive sessions (F5)

F5 opens an interactive session inside docker-tool's own frame, so the look stays the same. The docker CLI runs on a pseudo-terminal, and a built-in terminal emulator draws its screen. Every key goes to the container, including Ctrl-C. The help line shows the exceptions.

F5 on... What happens
An image Creates a container (docker container create -it <image>) and starts it attached. The image's default command runs (for example, a shell for ubuntu).
A stopped container created with -it Starts it attached (docker container start -ai), which gives you its session back.
A stopped container without -it Starts it in the background (docker container start).
A running container created with -it Attaches to it (docker container attach).
A running container without -it There is no terminal to attach to, so a dialog says so and offers a new shell instead (docker container exec -it <id> sh, using bash if the image has it).
A paused, restarting or dead container A message explains that F5 can't be used.
  • Ctrl-P Ctrl-Q detaches and leaves the container running. Press F5 on it later to attach again.
  • Typing exit in the shell, or ending the program, stops the container (for exec, only the extra shell ends).
  • When the session ends, its output stays on screen until you press a key.
  • The container is kept after the session (no --rm), so it appears in the image's container list. Remove it with D.

The embedded terminal handles what shells and full-screen programs such as vi, less and top use (colours, the alternate screen, line drawing). It has no scrollback and no mouse support.

Tests

.venv/bin/pytest

License

MIT — see LICENSE.

About

A tool built with Claude to manage the deletion of Docker images, which could evolve into something better

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages