TopRank Skills

Home / Claw Skills / DevOps / docker-container-cleaner
Official OpenClaw rules 36%

docker-container-cleaner

CLI tool to clean up stopped Docker containers, unused images, volumes, and networks to free up disk space.

Stars

0

Installs

0

Status

ACTIVE

Visibility

PUBLIC

安装方式

直接复制以下提示词,发送给你的 AI 助手即可完成安装。

请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 docker-container-cleaner 技能。 若已安装,则直接安装 docker-container-cleaner 技能。

Overview

Skill Key
derick001/docker-container-cleaner
Author
skill-factory
Source Repo
openclaw/skills
Version
1.0.0
Source Path
skills/derick001/docker-container-cleaner
Latest Commit SHA
7e58febc31457863d97bdd0b5d01eacfb19c404e

Extracted Content

SKILL.md excerpt

# Docker Container Cleaner

## What This Does

A CLI tool that helps clean up Docker resources to free up disk space. It can:
- List and remove stopped containers
- Remove dangling images (images with no tag)
- Remove unused images (not used by any container)
- Remove unused volumes
- Remove unused networks
- Perform a "prune all" operation (Docker system prune)

The tool provides a safe, interactive mode by default, showing what will be removed and asking for confirmation before deleting anything.

## When To Use

- Your Docker disk usage is growing and you need to free up space
- You have many stopped containers that are no longer needed
- You have old, unused images taking up disk space
- You want to clean up Docker resources in a controlled, safe way
- You need to automate Docker cleanup in scripts or CI/CD pipelines

## Usage

Interactive cleanup (recommended for first use):
```bash
python3 scripts/main.py clean
```

Remove stopped containers only:
```bash
python3 scripts/main.py clean --containers
```

Remove dangling images only:
```bash
python3 scripts/main.py clean --images --dangling
```

Remove unused images (all images not used by containers):
```bash
python3 scripts/main.py clean --images --unused
```

Remove unused volumes:
```bash
python3 scripts/main.py clean --volumes
```

Remove unused networks:
```bash
python3 scripts/main.py clean --networks
```

Force cleanup (no confirmation):
```bash
python3 scripts/main.py clean --all --force
```

Dry run (show what would be removed):
```bash
python3 scripts/main.py clean --all --dry-run
```

## Examples

### Example 1: Interactive cleanup

```bash
python3 scripts/main.py clean
```

Output:
```
Docker Cleanup Tool
===================

Found resources:
- Stopped containers: 3 (using 1.2GB)
- Dangling images: 5 (using 850MB)
- Unused images: 2 (using 450MB)
- Unused volumes: 1 (using 100MB)
- Unused networks: 0

Total disk space that can be freed: 2.6GB

What would you like to clean up?
1. Remove stopped contai...

README excerpt

# Docker Container Cleaner

A command-line tool to clean up Docker resources (containers, images, volumes, networks) to free up disk space.

## Installation

This skill requires:
- Python 3.x
- **Docker**: Must be installed and the Docker daemon must be running
- **Docker CLI**: Must be available in PATH (`docker` command)

Optional but recommended:
```bash
pip install docker
```

The Docker SDK for Python provides better performance and more reliable operations than shelling out to the `docker` CLI.

## Quick Start

```bash
# Interactive cleanup (recommended for first use)
python3 scripts/main.py clean

# Show current Docker resource usage
python3 scripts/main.py status

# Remove stopped containers only
python3 scripts/main.py clean --containers

# Remove dangling images only
python3 scripts/main.py clean --images --dangling

# Force cleanup of everything (no confirmation)
python3 scripts/main.py clean --all --force

# Dry run (show what would be removed)
python3 scripts/main.py clean --all --dry-run
```

## Command Reference

### `status` command
Show current Docker resource usage.

```
python3 scripts/main.py status [OPTIONS]
```

Options:
- `--format`: Output format: `table` (human-readable) or `json`. Default: `table`
- `--verbose`: Show detailed information

### `clean` command
Clean up Docker resources.

```
python3 scripts/main.py clean [OPTIONS]
```

Options:
- `--containers`: Remove stopped containers
- `--images`: Remove images (requires --dangling or --unused)
- `--dangling`: Remove dangling images (images with no tag)
- `--unused`: Remove unused images (not used by any container)
- `--volumes`: Remove unused volumes
- `--networks`: Remove unused networks
- `--all`: Clean all resource types (equivalent to --containers --images --volumes --networks)
- `--force`: Skip confirmation prompts
- `--dry-run`: Show what would be removed without actually removing
- `--yes`: Auto-answer "yes" to all prompts
- `--no-interactive`: Disable interactive mode (use with -...

Related Claw Skills