Skip to content

clipinski/dclean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dclean

Cross‑platform (Linux and macOS) Docker cleanup utility that removes:

  • All containers (running or stopped)
  • All volumes (including named volumes)
  • All images
  • Builder cache

Warning: This is destructive and irreversible.

Requirements

  • Docker CLI available on PATH
  • Docker daemon reachable for most operations

Installation

Linux

Make the script executable:

chmod +x /path/to/dclean/dclean

Install to your PATH (choose one):

# User install (no sudo)
mkdir -p ~/.local/bin
ln -sf /path/to/dclean/dclean ~/.local/bin/dclean
# Or copy
cp /path/to/dclean/dclean ~/.local/bin/dclean
# Ensure ~/.local/bin is in PATH (uncomment your shell):
# bash:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
# zsh:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
# System-wide (requires sudo)
sudo ln -sf /path/to/dclean/dclean /usr/local/bin/dclean
# Or copy
sudo cp /path/to/dclean/dclean /usr/local/bin/dclean

Verify:

dclean help

macOS

Make the script executable:

chmod +x /path/to/dclean/dclean

Install to your PATH (choose one):

# System-wide (recommended)
sudo ln -sf /path/to/dclean/dclean /usr/local/bin/dclean
# Or copy
sudo cp /path/to/dclean/dclean /usr/local/bin/dclean
# Optional: user install (add ~/.local/bin to PATH)
mkdir -p ~/.local/bin
ln -sf /path/to/dclean/dclean ~/.local/bin/dclean
# Or copy
cp /path/to/dclean/dclean ~/.local/bin/dclean
# Ensure ~/.local/bin is in PATH (uncomment your shell):
# bash:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
# zsh:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc

Verify:

dclean help

Usage

dclean                 # show usage/help
dclean all             # containers → volumes → images → cache
dclean containers      # stop and remove all containers (force)
dclean volumes         # remove all volumes
dclean images          # remove all images (force)
dclean cache           # prune builder cache

Examples:

dclean
dclean all
dclean containers
dclean images
dclean volumes
dclean cache

Behavior and Safety

  • Designed to be destructive for a clean slate
  • Empty-result handling prevents errors like:
    • docker: 'docker rm' requires at least 1 argument
  • Uses chunking with xargs -n 100 to avoid long argument lists
  • Avoids GNU-only flags so it works on macOS and Linux
  • Falls back to docker system prune -f if docker builder prune -f fails

License

MIT — see LICENSE.

About

Cross‑platform Bash script to clean Docker containers, volumes, images, and build cache.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages