docker-destructive-guardrails
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocker Destructive Command Guardrails
Docker 破坏性命令防护栏
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.
此skill提供了跨产品的破坏性或不可逆Docker CLI操作策略:删除数据、移除资源或以其他方式无法撤销的命令。只要任务可能合理导致运行这些命令之一,即使从未直接命名该命令,都应使用它。它涵盖没有归属到更具体skill中的通用Docker CLI命令,并索引其他破坏性命令(Compose、sandbox、Desktop)在何处被文档化。
When to use this skill
何时使用此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, or standalone (non-Compose)docker context rm/docker volume rmas a fix for an unrelated problem (disk space, a stuck container, a stale network, a broken build cache, an old builder or volume)docker volume prune - The user wants a cross-product overview of destructive commands across Docker skills
在以下情况下激活此skill:
- 用户要求"清理"、"清除缓存"、"重新开始"、"全部擦除"、"核平"、"重置"、"强制移除"或"拆掉"Docker资源而未指定具体命令
- agent正在考虑将、
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或独立(非Compose)的docker context rm/docker volume rm作为无关问题(磁盘空间、卡住的容器、过时的网络、损坏的构建缓存、旧的builder或volume)的修复方案docker volume prune - 用户希望跨Docker skill获得破坏性命令的跨产品概览
Do not use this skill when
不应使用此skill的情况
Do not use this skill when:
- The destructive command in question is Compose-specific (,
docker compose down -v,docker compose rm -v/docker volume rmin a Compose project) — usedocker volume prunedirectly, which owns that guidance in full detaildocker-compose-patterns - The task is authoring or reviewing a Dockerfile or with no cleanup or deletion involved
compose.yaml - The operation is non-Docker (git, filesystem, cloud resources) — this skill covers Docker CLI operations only
在以下情况下不应使用此skill:
- 涉及的破坏性命令是Compose特有的(、
docker compose down -v、Compose项目中的docker compose rm -v/docker volume rm)——直接使用docker volume prune,它完整地拥有该指南的所有细节docker-compose-patterns - 任务是编写或审查Dockerfile或,且不涉及清理或删除
compose.yaml - 操作是非Docker的(git、文件系统、云资源)——此skill仅涵盖Docker CLI操作
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 for exact flags and the safe, scoped alternative for each.
references/docker-cli-destructive-commands.mdThe container-lifecycle commands — , , , and — don't all carry the same risk, so they're split into two tiers below instead of one flat rule. 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.
docker rmdocker rm -fdocker container prunedocker killdocker stop以下每个命令的核心规则:**准确说明将被删除、停止或丢失的内容,并在运行之前获得用户的明确确认。**切勿将破坏性命令作为默认的故障排除或"直接清理一下"的反射行为——磁盘空间、卡住的容器和过时的缓存几乎总是有更狭窄、非破坏性的修复方案。参见了解确切标志和每个命令的安全、有范围的替代方案。
references/docker-cli-destructive-commands.md容器生命周期命令——、、和——并非都承载相同的风险,因此它们被分为下面的两个层级而不是一个平坦规则。遵循一个相关但不同的可逆操作规则,位于层级之后。此列表中的每个其他命令都遵循上述平坦规则,无例外:说明将丢失的内容,获得明确确认,并在运行之前等待用户的回答。
docker rmdocker rm -fdocker container prunedocker killdocker stopTier 1 — low-friction container cleanup
层级 1 — 低摩擦容器清理
Applies only to on an already-stopped container and on a container the agent itself created and started earlier in the same session purely for testing or debugging — the carve-out applies even when the container is still running, since that's the only reason 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 rule below applies to every other case.
docker rm <name>docker rm -f <name>-f-fdocker rm -f仅适用于对已停止容器的,以及agent在同一会话中先前创建并启动的纯粹用于测试或调试的容器的——例外即使容器仍在运行也适用,因为这是唯一需要的理由。以下所有条件必须成立:容器已停止,或由agent本会话自行创建/启动用于测试/调试;没有已知的未持久化状态处于风险中;操作针对一个特定的、已识别的容器而不是无范围的清扫;且agent是响应会话中的明确用户请求而行动,而非自行主动。当所有条件都成立时,agent移除容器,说明其做了什么,然后继续——不需要先进行阻塞性确认。层级2的规则适用于其他所有情况。
docker rm <name>docker rm -f <name>-f-fdocker rm -fTier 2 — container commands needing confirmation
层级 2 — 需要确认的容器命令
docker killdocker container prunedocker rm -fdocker rm -f $(docker ps -aq)docker killdocker container prunedocker rm -fdocker rm -f $(docker ps -aq)docker stop
— reversible, outside the tier model
docker stopdocker stop
— 可逆,在层级模型之外
docker stopdocker stopdocker start- — deletes stopped containers, unused networks, dangling images, and build cache;
docker system prunealso deletes unused tagged images, and-aalso deletes unused anonymous volumes (named volumes are untouched — deleting those needs a separate--volumes).docker volume rm - /
docker rmi— deletes a specific image; see the reference fordocker image rm's exact (partly unverified) override behavior on multi-tag/referenced images.-f - — deletes every image not referenced by any container, running or stopped, not just dangling ones.
docker image prune -a - — deletes the specifically named network(s) passed as arguments; see the reference for how its
docker network rmflag differs from-fbelow.docker context rm -f - — deletes every custom network not attached to a container.
docker network prune - — clears the BuildKit cache;
docker builder prune/-aalso removes internal helper/frontend images and cache shared with other build outputs, forcing a cold rebuild for anyone using that cache.--all - — removes a builder instance, distinct from the cache
docker buildx rmclears — see the reference for flag details.docker builder prune - — deletes a context's local connection config; doesn't affect remote resources but may not be trivially reconstructable. Unlike
docker context rmabove,docker network rm -fgenuinely forces removal even if the context is currently in use.docker context rm -f - /
docker volume rm(standalone, no Compose project in play) — deletes volume data directly and irreversibly;docker volume prune/docker volume prune -awidens the default anonymous-only scope to named volumes too. For a Compose project's own volumes, use--allinstead (see Related skills); for a volume declareddocker-compose-patternsin a compose.yaml but not managed by that Compose project, this skill's guidance applies since Compose won't touch it viaexternal: true.down -v
docker stopdocker start- — 删除已停止的容器、未使用的网络、悬空镜像和构建缓存;
docker system prune还删除未使用的带标签镜像,-a还删除未使用的匿名卷(命名卷不受影响——删除这些需要单独的--volumes)。docker volume rm - /
docker rmi— 删除特定镜像;参见参考文档了解docker image rm对多标签/被引用镜像的精确(部分未验证的)覆盖行为。-f - — 删除所有未被任何容器引用的镜像(无论运行中还是已停止),不仅仅是悬空镜像。
docker image prune -a - — 删除作为参数传入的特定命名网络;参见参考文档了解其
docker network rm标志与下面的-f有何不同。docker context rm -f - — 删除所有未附加到容器的自定义网络。
docker network prune - — 清除BuildKit缓存;
docker builder prune/-a还移除内部辅助/frontend镜像以及与其他构建输出共享的缓存,强制任何使用该缓存的人进行冷重建。--all - — 移除builder实例,与
docker buildx rm清除的缓存不同——参见参考文档了解标志细节。docker builder prune - — 删除上下文的本地连接配置;不影响远程资源,但可能不容易重建。与上面的
docker context rm不同,docker network rm -f确实强制移除,即使上下文当前正在使用中。docker context rm -f - /
docker volume rm(独立,无Compose项目)——直接且不可逆地删除卷数据;docker volume prune/docker volume prune -a将默认的仅匿名范围扩展到包括命名卷。对于Compose项目自己的卷,请改用--all(参见相关skill);对于在compose.yaml中声明为docker-compose-patterns但不由该Compose项目管理的卷,此skill的指南适用,因为Compose不会通过external: true触碰它。down -v
Related skills
相关skill
- For Compose-specific destructive commands (,
docker compose down -v,docker compose rm -v/docker volume rmin a Compose context), usedocker volume prune— it owns that guidance in full detail; this skill only indexes it. This skill owns the standalone (non-Compose) case fordocker-compose-patterns/docker volume rmitself — see Core guidance anddocker volume prune.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), usesbx prune— 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 (seedocker-sandboxes-lifecyclefor tracking status); do not assume their content until that skill ships.references/cross-skill-destructive-command-index.md
- 对于Compose特定的破坏性命令(、
docker compose down -v、Compose上下文中的docker compose rm -v/docker volume rm),使用docker volume prune——它完整地拥有该指南的所有细节;此skill仅索引它。此skill自己拥有独立(非Compose)情况下的docker-compose-patterns/docker volume rm——参见核心指南和docker volume prune。references/docker-cli-destructive-commands.md - 对于Dockerfile内部机制、构建缓存和镜像大小优化(非破坏性问题),使用。
docker-build-strategies - 对于首次Docker项目脚手架搭建,使用。
docker-project-foundations - 对于sandbox(sbx)破坏性命令(、
sbx rm),使用sbx prune——它完整地拥有该指南的所有细节;此skill仅索引它。Docker Desktop破坏性命令防护栏在合并后将拥有自己的skill(参见docker-sandboxes-lifecycle了解跟踪状态);在该skill发布之前,不要假设其内容。references/cross-skill-destructive-command-index.md
References
参考文档
- — Per-command breakdown of exact flags, what's deleted, and the safe/scoped alternative for each generic Docker CLI destructive command.
references/docker-cli-destructive-commands.md - — Cross-product table of destructive commands across all Docker skills, including a pending placeholder for Docker Desktop.
references/cross-skill-destructive-command-index.md
- — 每个通用Docker CLI破坏性命令的逐命令分解:确切标志、删除内容以及安全/有范围的替代方案。
references/docker-cli-destructive-commands.md - — 所有Docker skill中破坏性命令的跨产品表,包括Docker Desktop的待定占位符。
references/cross-skill-destructive-command-index.md
Assets
资源
This skill has no bundled assets.
此skill没有捆绑资源。
Checks
检查
- — Manual review runbook, including example bad/good dialogues for handling destructive-command requests.
checks/verification.md
- — 手动审查运行手册,包括处理破坏性命令请求的示例不良/良好对话。
checks/verification.md