Docker Destructive Guardrails
DockerOfficialPublished by Docker
- Skill
- Guidelines
- Software development
- Apache-2.0
- No issues found
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
Download the skill as a ZIP:
https://autogineer.com/agent-skills/docker/docker-destructive-guardrails/downloadUnzip 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 pruneas 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 prunein a Compose project) — usedocker-compose-patternsdirectly, which owns that guidance in full detailThe task is authoring or reviewing a Dockerfile or
compose.yamlwith no cleanup or deletion involvedThe 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;-aalso deletes unused tagged images, and--volumesalso deletes unused anonymous volumes (named volumes are untouched — deleting those needs a separatedocker 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-fflag differs fromdocker context rm -fbelow.docker network prune— deletes every custom network not attached to a container.docker builder prune— clears the BuildKit cache;-a/--allalso 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 cachedocker builder pruneclears — 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. Unlikedocker network rm -fabove,docker context rm -fgenuinely 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/--allwidens the default anonymous-only scope to named volumes too. For a Compose project's own volumes, usedocker-compose-patternsinstead (see Related skills); for a volume declaredexternal: truein a compose.yaml but not managed by that Compose project, this skill's guidance applies since Compose won't touch it viadown -v.
Related skills
For Compose-specific destructive commands (
docker compose down -v,docker compose rm -v,docker volume rm/docker volume prunein a Compose context), usedocker-compose-patterns— it owns that guidance in full detail; this skill only indexes it. This skill owns the standalone (non-Compose) case fordocker volume rm/docker volume pruneitself — see Core guidance andreferences/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), usedocker-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 (seereferences/cross-skill-destructive-command-index.mdfor 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
- ATTRIBUTION.mdAdded by AutoGineer850 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md10.0 KiB
- agents/openai.yaml384 B
- checks/verification.md8.6 KiB
- references/cross-skill-destructive-command-index.md3.2 KiB
- references/docker-cli-destructive-commands.md12.7 KiB
- skill.yaml1.4 KiB
references/docker-cli-destructive-commands.md
Docker CLI Destructive Commands
Detailed breakdown of the generic Docker CLI commands this skill owns. For each command: what it deletes, the exact flags that widen the blast radius, and the safer/scoped alternative to reach for first.
Note: there is no top-level docker prune alias. Each resource type has its own subcommand — docker container prune, docker image prune, docker network prune, docker volume prune, docker system prune, and docker builder prune (a true alias of docker buildx prune — docker builder prune --help prints Usage: docker buildx prune). Don't assume a bare docker prune exists.
Container lifecycle: docker rm, docker rm -f, docker container prune, docker kill
These four commands remove or kill containers, but each widens the blast radius differently. See SKILL.md's Core guidance for the Tier 1/Tier 2 confirmation policy that applies to each — this section covers the exact flag behavior only.
docker rm <container> # stopped container only, fails on a running one
docker rm -f <container> # widens to a running container too, via SIGKILL
docker rm -f -v <container> # + removes anonymous volumes attached to it
docker container prune # removes all stopped containers on the host; no flag widens this to running ones
docker kill <container> # SIGKILL (or --signal <sig>) with no grace period, alwaysdocker rm(no-f) on a stopped container is a normal, low-risk, irreversible removal — the container was already stopped, so there's no live process being interrupted.-f/--forcewidensdocker rmto also work on a running container, sending it SIGKILL with no graceful shutdown; adding-vadditionally removes any anonymous volumes attached to that container.docker container pruneonly ever removes stopped containers — no flag widens its scope to running ones.docker killalways sends SIGKILL (or a custom signal via-s/--signal) with no grace period; it only applies to running containers, so there's no "already stopped, low-risk" case the way there is fordocker rm.
Safer alternative: target one specific, identified container by name or ID rather than sweeping every container on the host.
docker rm <name> # only the container that's actually stuck or finished
docker rm -f <name> # only if it's genuinely stuck and won't respond to docker stopIf several containers appear stuck, list them (docker ps -a) and confirm with the user which ones are safe to remove before force-removing more than one.
docker stop
docker stop <container> # SIGTERM, then SIGKILL after the timeout
docker stop -t <seconds> <container> # custom grace period before SIGKILL
docker stop -s <signal> <container> # custom initial signal instead of SIGTERMDoes not remove the container — it can be restarted afterward with
docker start. This is why it sits outside the Tier 1/Tier 2 removal model inSKILL.md's Core guidance, even though Docker Agent's runtime safety classifier still flags it as low-risk destructive.Sends
SIGTERM(or a custom signal via-s/--signal) and waits-t/--timeoutseconds (default 10) before force-killing withSIGKILL. Any unpersisted in-container state (e.g. an in-memory cache, an unflushed write) is lost at that point, the same as withdocker kill.
Safer alternative: this is already the lower-risk alternative to docker kill for a graceful shutdown — prefer it over docker kill unless the container is unresponsive to SIGTERM.
docker system prune
docker system prune # stopped containers, unused networks, dangling images, build cache
docker system prune -a # + all images not referenced by any container, running or stopped
docker system prune --volumes # + unused anonymous volumes and their data
docker system prune -a --volumes # everything above, combinedWithout flags, this already deletes stopped containers permanently — any container-local state not committed to an image or volume is gone.
-a/--allwidens image deletion from "dangling only" to "any image not referenced by any container, running or stopped," including tagged images that were deliberately pulled or built.--volumesprunes unused anonymous volumes only — named volumes (e.g. database data mounted via avolumes:entry) are never touched bysystem prune. Deleting a named volume requires a separate, explicitdocker volume rmand its own confirmation.docker system prune -a --volumesis still the widest-blast-radius form of this command and must never be run without first listing whatdocker system dfreports would be reclaimed, and getting explicit confirmation.
Safer alternative: inspect first, then prune narrowly.
docker system df # see what's actually consuming space, by category
docker container prune # stopped containers only
docker image prune # dangling (untagged) images only, no -a
docker builder prune # build cache not tied to existing imagesOnly add -a to docker image prune or --volumes to any prune command after the user has confirmed the specific resources named are safe to delete.
docker rmi / docker image rm
docker rmi <image> # or: docker image rm <image> — same command, two names
docker rmi -f <image> # force removal
docker rmi --no-prune <image> # skip removing now-untagged parent image layersdocker rmianddocker image rmare the same command under two names.-f/--force's own--helptext only says "Force removal of the image." It's commonly understood to override protection for an image with multiple tags or one referenced by a stopped (not running) container, but that exact override behavior isn't spelled out in the--helptext itself — treat it as documented-by-convention rather than confirmed, and get explicit confirmation before using-fon an image that might still be tagged or referenced elsewhere.--no-pruneskips the usual cleanup of now-untagged parent image layers.
Safer alternative: remove without -f first; only add -f after confirming with the user that no other tag or stopped container still needs the image.
docker image prune -a
docker image prune # dangling (untagged) images only
docker image prune -a # any image not used by an existing container-a/--allremoves tagged images too, not just dangling ones. An image that was pulled for later use, or built as a base for future work, is deleted if no container — running or stopped — still references it.Removed images must be re-pulled or rebuilt, which can be slow for large images or on a metered connection.
Safer alternative: run without -a first, and add a filter for age or label if more aggressive cleanup is genuinely needed.
docker image prune # dangling only, no risk to tagged images
docker image prune --filter "until=168h" # images older than 7 days, still requires confirmation before -adocker network rm
docker network rm <name>
docker network rm -f <name>Only removes the specifically named network(s) passed as arguments — there's no sweep behavior the way
docker network prunehas.-f/--forceondocker network rmonly suppresses a "network does not exist" error if the network is already gone — it does not override in-use protection. A network still attached to a running container is not force-removed bynetwork rm -f. This is different fromdocker context rm -fbelow, which genuinely forces removal of an in-use context — don't assume both-fflags behave the same way just because they share a name.
Safer alternative: this is already the scoped, targeted alternative to docker network prune below — confirm the network name with the user before running it.
docker network prune
docker network pruneRemoves every user-defined bridge/overlay network not currently attached to a running container. Networks with static IP assignments, custom subnets, or
external: truereferences from stopped-but-not-deleted Compose projects are deleted along with that configuration.
Safer alternative: remove a specific network by name with docker network rm <name> above, once confirmed unused.
docker builder prune
docker builder prune # cache not associated with any existing image
docker builder prune -a # + internal helper/frontend images and cache shared with other build outputsWithout
-a/--all, this is relatively low-risk — it only removes cache that no current image depends on.-a/--allalso removes build cache beyond what's dangling — including BuildKit's internal helper/frontend images and cache shared with other build outputs. Treat a full-awipe as forcing a cold rebuild for any consumer of that cache (local, CI, teammates using a shared cache backend).docker builder pruneis a true alias ofdocker buildx prune(see the top note) — the same cache is affected either way.
Safer alternative: run without -a unless the user has confirmed a full cache wipe is worth the next full rebuild.
docker buildx rm
docker buildx rm <builder>
docker buildx rm --all-inactive
docker buildx rm --keep-daemon <builder>
docker buildx rm --keep-state <builder>Removes a builder instance — its configuration/registration and, unless kept, its daemon/state — a different resource from the build cache covered by
docker builder pruneabove.--all-inactivewidens this to every inactive builder at once, not just the one named.--keep-daemon/--keep-statereduce what's deleted, but the builder's registration/reference itself is still removed either way.
Safer alternative: remove one named builder at a time rather than --all-inactive, and confirm with the user which builder(s) are no longer needed.
docker context rm
docker context rm <name>
docker context rm -f <name>Deletes the local context entry (endpoint URL, TLS material references, metadata) for connecting to a Docker host. It does not delete remote resources on that host, but it does delete the local configuration for reaching it.
-f/--forceondocker context rmgenuinely forces removal even if the context is currently in use (e.g. it's the active context) — seedocker network rmabove, whose same-named flag behaves differently.If the context was set up interactively (e.g. with a one-time token, a manually copied TLS bundle, or a since-rotated credential), it may not be trivially re-creatable.
Safer alternative: use docker context update <name> to fix a misconfigured endpoint or TLS setting instead of deleting and recreating the context.
docker volume rm
Standalone case only — no Compose project in play. If a compose.yaml is present and the volume belongs to that project, use docker-compose-patterns instead (docker compose down -v, Compose-managed anonymous volumes); this section does not duplicate or override that guidance.
docker volume rm <name>
docker volume rm -f <name>docker volume rm's own--helptext says plainly: "You cannot remove a volume that is in use by a container" — without force, it fails safely on an in-use volume.Whether
-f/--forcetruly force-removes an in-use volume, or merely suppresses a "no such volume" error the waydocker network rm -fdoes, is not disambiguated by--helptext alone. Treat this as an open question rather than asserting either behavior, and get explicit confirmation before using-fon a volume that might still be attached to a container.
Safer alternative: run without -f first; if it fails because the volume is in use, identify and stop/remove the container using it (with its own confirmation) before retrying, rather than reaching for -f.
docker volume prune
Standalone case only — no Compose project in play. For Compose-managed anonymous volumes, use docker-compose-patterns (docker compose down -v) instead.
docker volume prune # unused anonymous volumes only
docker volume prune -a # + unused named volumes tooDefault scope (no flags) is unused anonymous volumes only — this matches
docker system prune --volumes's scope documented above.-a/--allwidens this to unused named volumes too, confirmed by its own help text: "Remove all unused volumes, not just anonymous ones." A named volume holding database state that just isn't currently attached to a running container is deleted by-ajust as readily as a throwaway anonymous one.
Safer alternative: run without -a first, and confirm with the user which named volumes (if any) are genuinely safe to delete before adding -a.
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 or Docker.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download docker-destructive-guardrails.zip