Generated banner for Docker Destructive Guardrails
Generated logo for Docker Destructive Guardrails

Docker Destructive Guardrails

DockerOfficialPublished by Docker

  • Skill
  • Guidelines
  • Software development
  • Apache-2.0
  • No issues found

From the author

Use this skill before running, or recommending, any Docker command that deletes, wipes, resets, or otherwise irreversibly changes state — even if the user just says to "clean up", "clear the cache", "start fresh", "wipe everything", "nuke it", "reset", "force remove", or "tear down" Docker resources. Covers generic Docker CLI destructive operations not owned by a more specific skill — `docker rm`, `docker rm -f`, `docker container prune`, `docker kill`, `docker system prune`, `docker rmi`/`docker image rm`, `docker image prune -a`, `docker network rm`, `docker network prune`, `docker builder prune`, `docker buildx rm`, `docker context rm`, and standalone (non-Compose) `docker volume rm`/`docker volume prune`. Also indexes destructive commands owned by other Docker skills (Compose, sandbox, Desktop). Core rule — state exactly what will be lost and get explicit confirmation first, except narrow, low-friction Tier 1 container cleanup.
— the description by Docker

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill establishes a mandatory safety protocol for executing irreversible Docker CLI commands. It mandates that agents must clearly communicate the potential data loss or state changes to the user and obtain explicit confirmation before proceeding with any destructive action. The skill categorizes commands into tiers based on risk, providing a structured approach to container lifecycle management, system pruning, and resource removal while ensuring that non-destructive alternatives are prioritized.

What it does

  • Defines a mandatory confirmation policy for destructive Docker CLI commands.
  • Categorizes container cleanup into low-friction Tier 1 and high-risk Tier 2 operations.
  • Provides guidance on handling generic Docker CLI commands like prune, rm, and kill.
  • Distinguishes between reversible actions like stop and irreversible actions like rm.
  • Indexes destructive commands across other Docker-related skills.
  • Promotes the use of scoped, non-destructive alternatives for troubleshooting.

When to use it

  • When a user requests to clean up, wipe, or reset Docker resources.
  • When considering commands like docker rm, docker system prune, or docker kill.
  • When troubleshooting disk space or stale resources to ensure safe cleanup.
  • When you need to verify if a command requires explicit user confirmation.

Advantages

  • Prevents accidental data loss and irreversible state changes.
  • Standardizes the safety protocol for all Docker-related agent interactions.
  • Reduces the risk of interrupting critical running processes.
  • Encourages the use of safer, more precise troubleshooting methods.

Usage examples

“Can you clean up my Docker environment to free up space?”
The agent identifies the request as a potential system prune, lists exactly what will be removed (stopped containers, unused networks, dangling images), and asks for explicit confirmation.
“Force remove all my containers now.”
The agent identifies this as a high-risk Tier 2 operation, explains the impact of removing all containers, and waits for the user's explicit approval before executing.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/docker/docker-destructive-guardrails/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip docker-destructive-guardrails.zip -d .agents/skills

Documentation by Docker

Docker Destructive Command Guardrails

Overview

This skill provides the cross-product policy for handling destructive or irreversible Docker CLI operations: commands that delete data, remove resources, or otherwise cannot be undone. Use it whenever a task could reasonably lead to running one of these commands, even if the user never names the command directly. It covers the generic Docker CLI commands with no home in a more specific skill, and it indexes where other destructive commands (Compose, sandbox, Desktop) are documented.

When to use this skill

Activate this skill when:

  • The user asks to "clean up", "clear the cache", "start fresh", "wipe everything", "nuke it", "reset", "force remove", or "tear down" Docker resources without naming a specific command

  • The agent is considering docker rm, docker rm -f, docker container prune, docker kill, docker stop, docker system prune, docker rmi, docker image rm, docker image prune -a, docker network rm, docker network prune, docker builder prune, docker buildx rm, docker context rm, or standalone (non-Compose) docker volume rm/docker volume prune as a fix for an unrelated problem (disk space, a stuck container, a stale network, a broken build cache, an old builder or volume)

  • The user wants a cross-product overview of destructive commands across Docker skills

Do not use this skill when

Do not use this skill when:

  • The destructive command in question is Compose-specific (docker compose down -v, docker compose rm -v, docker volume rm/docker volume prune in a Compose project) — use docker-compose-patterns directly, which owns that guidance in full detail

  • The task is authoring or reviewing a Dockerfile or compose.yaml with no cleanup or deletion involved

  • The operation is non-Docker (git, filesystem, cloud resources) — this skill covers Docker CLI operations only

Core guidance

The core rule for every command below: state exactly what will be deleted, stopped, or lost, and get explicit confirmation from the user before running it. Never run a destructive command as a default troubleshooting or "just clean it up" reflex — disk space, stuck containers, and stale caches almost always have a narrower, non-destructive fix. See references/docker-cli-destructive-commands.md for exact flags and the safe, scoped alternative for each.

The container-lifecycle commands — docker rm, docker rm -f, docker container prune, and docker kill — don't all carry the same risk, so they're split into two tiers below instead of one flat rule. docker stop follows a related but distinct reversible-action rule right after the tiers. Every other command in this list follows the flat rule stated above with no exceptions: state what's lost, get explicit confirmation, and wait for the user's answer before running it.

Tier 1 — low-friction container cleanup

Applies only to docker rm <name> on an already-stopped container and docker rm -f <name> on a container the agent itself created and started earlier in the same session purely for testing or debugging — the -f carve-out applies even when the container is still running, since that's the only reason -f would be needed. All of the following must hold: the container is already stopped, or was created/started by the agent itself this session for testing/debugging; there's no known unpersisted state at risk; the action targets one specific, identified container rather than an unscoped sweep; and the agent is acting on an explicit user ask this session, not its own initiative. When every condition holds, the agent removes the container, states what it did, and proceeds — no blocking confirmation is required first. Tier 2's docker rm -f rule below applies to every other case.

Tier 2 — container commands needing confirmation

docker kill is always Tier 2 (see the reference for why no stopped-container exception exists for it). Also Tier 2: docker container prune (it always sweeps every stopped container on the host, never just the one the agent is cleaning up), docker rm -f on any container that doesn't meet every Tier 1 condition above (in particular, a running container the agent didn't create/start this session, or one it did but is acting on without an explicit user ask), any other unscoped sweep regardless of container state (e.g. docker rm -f $(docker ps -aq), "remove/kill all containers"), a container the agent didn't create and has no context on, and any action taken on the agent's own initiative rather than an explicit user ask. These carry the same confirmation bar as every flat-rule command in this skill: state exactly what will be lost and get explicit confirmation before running anything — no exception carved out.

docker stop — reversible, outside the tier model

docker stop doesn't remove anything — the container still exists and can be restarted with docker start — so it sits outside the Tier 1/Tier 2 removal model above. It's still in scope for this skill because it interrupts a running process (SIGTERM, then SIGKILL after the timeout) and discards any unpersisted in-container state. On the agent's own test/debug container from this session, treat it like Tier 1: stop it and state what happened, no blocking confirmation required. On any other container, state that it will stop running and any unsaved in-memory state will be lost, then get confirmation first.

  • docker system prune — deletes stopped containers, unused networks, dangling images, and build cache; -a also deletes unused tagged images, and --volumes also deletes unused anonymous volumes (named volumes are untouched — deleting those needs a separate docker volume rm).

  • docker rmi / docker image rm — deletes a specific image; see the reference for -f's exact (partly unverified) override behavior on multi-tag/referenced images.

  • docker image prune -a — deletes every image not referenced by any container, running or stopped, not just dangling ones.

  • docker network rm — deletes the specifically named network(s) passed as arguments; see the reference for how its -f flag differs from docker context rm -f below.

  • docker network prune — deletes every custom network not attached to a container.

  • docker builder prune — clears the BuildKit cache; -a/--all also removes internal helper/frontend images and cache shared with other build outputs, forcing a cold rebuild for anyone using that cache.

  • docker buildx rm — removes a builder instance, distinct from the cache docker builder prune clears — see the reference for flag details.

  • docker context rm — deletes a context's local connection config; doesn't affect remote resources but may not be trivially reconstructable. Unlike docker network rm -f above, docker context rm -f genuinely forces removal even if the context is currently in use.

  • docker volume rm / docker volume prune (standalone, no Compose project in play) — deletes volume data directly and irreversibly; docker volume prune -a/--all widens the default anonymous-only scope to named volumes too. For a Compose project's own volumes, use docker-compose-patterns instead (see Related skills); for a volume declared external: true in a compose.yaml but not managed by that Compose project, this skill's guidance applies since Compose won't touch it via down -v.

  • For Compose-specific destructive commands (docker compose down -v, docker compose rm -v, docker volume rm/docker volume prune in a Compose context), use docker-compose-patterns — it owns that guidance in full detail; this skill only indexes it. This skill owns the standalone (non-Compose) case for docker volume rm/docker volume prune itself — see Core guidance and references/docker-cli-destructive-commands.md.

  • For Dockerfile internals, build caching, and image size optimization (non-destructive concerns), use docker-build-strategies.

  • For first-time Docker project scaffolding, use docker-project-foundations.

  • For sandbox (sbx) destructive commands (sbx rm, sbx prune), use docker-sandboxes-lifecycle — it owns that guidance in full detail; this skill only indexes it. Docker Desktop destructive-command guardrails will live in their own skill once merged (see references/cross-skill-destructive-command-index.md for tracking status); do not assume their content until that skill ships.

References

  • references/docker-cli-destructive-commands.md — Per-command breakdown of exact flags, what's deleted, and the safe/scoped alternative for each generic Docker CLI destructive command.

  • references/cross-skill-destructive-command-index.md — Cross-product table of destructive commands across all Docker skills, including a pending placeholder for Docker Desktop.

Assets

This skill has no bundled assets.

Checks

  • checks/verification.md — Manual review runbook, including example bad/good dialogues for handling destructive-command requests.

Files

checks/verification.md

Verification Runbook: Destructive Command Guardrails

This skill documents behavioral policy rather than a generated artifact, so verification is manual review rather than running a validator against generated output. Run these checks whenever this skill or a skill it references is updated.

1. Generic command list matches current Docker CLI behavior

For each command in references/docker-cli-destructive-commands.md (docker rm, docker container prune, docker kill, docker stop, docker system prune, docker rmi/docker image rm, docker image prune -a, docker network rm, docker network prune, docker builder prune, docker buildx rm, docker context rm, standalone docker volume rm/docker volume prune), confirm the documented flags and behavior still match the installed Docker CLI's --help output:

for cmd in "rm" "container prune" "kill" "stop" "system prune" "rmi" "image prune" \
           "network rm" "network prune" "builder prune" "buildx rm" "context rm" \
           "volume rm" "volume prune"; do
  docker $cmd --help
done

Flag names, defaults, and what each flag deletes change occasionally between Docker releases. If --help output has drifted from what's documented, update references/docker-cli-destructive-commands.md and SKILL.md's Core guidance section together.

2. Cross-skill index rows match each linked skill's actual guardrail content

For every row in references/cross-skill-destructive-command-index.md whose owning skill is not this one (currently docker-compose-patterns and docker-sandboxes-lifecycle), re-read that skill's actual destructive-command guidance and confirm:

  • The command names in the index row still match what the owning skill documents (no renamed flags, no removed commands).

This is a manual check, not an automated one — nothing currently diffs the index against the owning skill's actual content, so drift only gets caught if this step is actually run. For the pending Docker Desktop row, confirm the PR referenced in references/cross-skill-destructive-command-index.md is still open and unmerged before leaving the "pending" note in place — update the row once that skill ships.

3. Tier 1 examples carry no Tier 2/3-style blocking-confirmation language

The container-lifecycle tiering model (docker rm, docker rm -f, docker container prune, docker kill) splits into Tier 1 (state-and-proceed, no blocking confirmation) and Tier 2 (same confirmation bar as the flat-rule commands). The automated eval-checks.yaml checks mostly only assert coarse existence (a "### Tier 1" heading exists, a "### Tier 2" heading exists, specific commands are mentioned) — grep has no concept of proximity or section-scoping in general, so most of this distinction must be checked by hand. One narrow exception is automated: ddg-kill-not-listed-under-tier1 uses a cross-line file_must_not_match pattern to catch the specific, common mistake of docker kill text appearing between the Tier 1 and Tier 2 headings — that single coarse guard doesn't cover the rest of the distinction below, which still needs manual review:

  • For every example listed under the Tier 1 heading in SKILL.md (container already stopped, or created/started by the agent itself this session, no known unpersisted state at risk, one specific identified container — e.g. docker rm <stopped-container>, docker rm -f <agent's-own-just-created-test-container>), confirm the surrounding text does NOT say to ask for confirmation or wait for the user before acting. It should describe stating what was done, not asking permission first.

  • For every example listed under the Tier 2 heading, and for every flat-rule command (volumes, images, networks, builder/buildx, context, docker system prune), confirm the surrounding text DOES require explicit confirmation before running the command, with no exception carved out.

  • Specifically confirm docker kill is documented only under Tier 2, never listed as a Tier 1 example — it has no stopped-container exception.

  • Specifically confirm docker container prune is documented only under Tier 2, never listed as a Tier 1 example — it always sweeps every stopped container on the host, so it can never target "one specific, identified container" the way Tier 1 requires.

  • Specifically confirm an unscoped sweep (e.g. docker rm -f $(docker ps -aq), "force remove all containers") is documented as Tier 2 even when every example nearby is Tier 1 — scope (single named container vs. sweep), not container state alone, is what should gate the tier for a sweep.

If any Tier 1 example reads like it requires the user to wait for permission, or any Tier 2/3 example reads like it can proceed without confirmation, fix the prose before merging — the automated checks will not catch this misplacement.

4. docker network rm -f and docker context rm -f are documented with distinct semantics

These two -f flags do different things and must not be conflated. Read both entries in references/docker-cli-destructive-commands.md side by side and confirm they still use language that makes the difference unambiguous (one suppresses a "not found" error only and does not override in-use protection, the other genuinely forces removal of an in-use resource). A reader skimming just the -f flag name should not come away assuming both behave the same way.

5. Standalone volume content does not contradict docker-compose-patterns's Compose-scoped content

docker volume rm/docker volume prune now have two homes: this skill covers the standalone (non-Compose) case, and docker-compose-patterns covers the Compose-context case. Before merging changes to either skill's volume guidance:

  • Confirm this skill's guidance (in SKILL.md and references/docker-cli-destructive-commands.md) is scoped to "no Compose project in play" and doesn't duplicate or override docker-compose-patterns's Compose-specific advice (e.g. docker compose down -v behavior, anonymous volumes tied to Compose-managed containers).

  • Confirm docker-compose-patterns's SKILL.md "Destructive commands" section is narrowed to the Compose-context case only, and its cross-reference to this skill (for the standalone case) is accurate and not circular.

  • Confirm neither skill claims sole ownership of docker volume rm/docker volume prune in a way that would make an agent miss the other skill's applicable case (Compose project present vs. absent).

6. No destructive command is documented as safe without confirmation

Grep this skill's files for the command list and confirm every one is paired with a confirmation requirement, not a "safe to run automatically" statement:

grep -n "docker rm -f\|docker container prune\|docker kill\|docker system prune\|docker rmi\|docker image rm\|docker image prune -a\|docker network rm\|docker network prune\|docker builder prune\|docker buildx rm\|docker context rm\|docker volume rm\|docker volume prune" \
  skills/docker-destructive-guardrails/SKILL.md \
  skills/docker-destructive-guardrails/references/*.md

Every match should appear alongside guidance to state what will be lost and get explicit confirmation — never alongside language suggesting the command is safe to run unprompted.

Example dialogues

Bad: agent runs the destructive command unprompted

User: Docker's taking up a lot of disk space, can you clean things up?

Agent: Sure, running docker system prune -a --volumes now... Done, freed 12GB.

This is wrong even though it "worked": the agent deleted every unused image and every unused anonymous volume without saying what would be removed or waiting for the user to agree.

Good: agent states impact and waits for confirmation

User: Docker's taking up a lot of disk space, can you clean things up?

Agent: I can reclaim space, but there are a few options with different levels of risk:

  • docker container prune — removes stopped containers only. Low risk.

  • docker image prune — removes dangling (untagged) images only. Low risk.

  • docker image prune -a — removes all images not referenced by any container, running or stopped, including tagged ones you might want to reuse. You'd need to re-pull or rebuild them later.

  • docker system prune -a --volumes — the most aggressive option. This also deletes every unused anonymous volume (named volumes, like database data, aren't touched — those need a separate docker volume rm).

Want me to start with the low-risk options (containers + dangling images), or do you want the more aggressive cleanup?

The agent names what each option removes, orders them by risk, and does not run anything until the user picks one.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

The author says: Applies to any Docker CLI version. This is a behavioral guardrail skill, not a Dockerfile or Compose authoring skill.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Docker
Publisher
Docker (Official)
Source
docker/skills · skills/docker-destructive-guardrails · commit 9f04a05
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Docker.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download docker-destructive-guardrails.zip