Inspect, start, stop, restart and clean up Docker containers with real docker CLI commands; read-only checks first, confirmation before any destructive change.
---
name: docker-container-manager
description: Inspects and manages local Docker containers with the docker CLI — list, status, logs, resource usage, start, stop, restart, create from an image and remove — showing the exact command first and asking before anything that stops, deletes or prunes. Use when asked about running containers, container logs, why a container exited, or to start, stop or clean up containers.
compatibility: Requires the docker CLI and access to a running Docker daemon (Docker Desktop, Docker Engine or a configured remote context).
metadata:
version: "1.0.0"
category: "DevOps"
---
# Docker Container Manager
Translate the user's request into explicit `docker` commands, run read-only commands freely, and treat anything that changes state as a proposal until the user confirms.
## When not to use
- Containers are managed by Compose, Kubernetes or Swarm. Use `docker compose ...` in the project directory or kubectl instead; changing those containers directly is overwritten by the orchestrator.
- The request needs access to a remote production host the user has not already configured as a Docker context.
## Preflight
1. `docker version` and `docker context show`: confirm the CLI can reach a daemon and which one. If you see "Cannot connect to the Docker daemon", stop and tell the user to start Docker or select the right context. Do not try to install or start it yourself.
2. Resolve names: containers can be addressed by name or ID prefix. Run `docker ps -a --filter name=<text>` and use the exact name you found.
## Read-only commands (run without asking)
| Need | Command |
|---|---|
| Running containers | `docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'` |
| All containers, including stopped | `docker ps -a` (add `--filter status=exited`) |
| Why it exited | `docker inspect <name> --format '{{.State.Status}} exit={{.State.ExitCode}} oom={{.State.OOMKilled}} err={{.State.Error}}'` |
| Logs | `docker logs --tail 200 --timestamps <name>` (`--since 10m` to narrow; avoid unbounded `-f` in an agent) |
| Resource use | `docker stats --no-stream` |
| Health | `docker inspect <name> --format '{{json .State.Health}}'` |
## State-changing commands (show, then confirm)
| Need | Command | Notes |
|---|---|---|
| Create and run | `docker run -d --name <name> -p 127.0.0.1:<host>:<container> <image>:<tag>` | Pin a tag; pass secrets with `--env-file`, never inline in the chat |
| Start / stop / restart | `docker start <name>`, `docker stop <name>`, `docker restart <name>` | `stop` sends SIGTERM, then SIGKILL after the timeout |
| Remove a stopped container | `docker rm <name>` | Container filesystem changes are lost; named volumes remain |
| Remove a running container | `docker rm -f <name>` | Kills it first; confirm explicitly |
| Clean up | `docker container prune` | List what would be removed with `docker ps -a --filter status=exited` first |
Never run `docker system prune`, `docker volume prune`, `rm -v` or anything that deletes volumes unless the user asked for that exact effect after seeing the list of volumes affected.
## Workflow
1. Run the preflight.
2. Map the request to commands from the tables. For vague requests ("clean up containers") list candidates and ask which to act on.
3. For state changes, show the exact command and the affected containers, wait for confirmation, run it, then re-run `docker ps -a` to show the result.
4. Report what the CLI returned. If a command fails, quote the error and suggest the next diagnostic.
## Example
Request: "my api container keeps dying, check it and restart it."
Good result: `docker ps -a --filter name=api` finds `shop-api` exited; `docker inspect` shows exit code 137 with OOMKilled=true; the last 200 log lines are summarised; the agent explains the memory limit, proposes `docker start shop-api` (or recreating it with a higher `--memory`), and runs it only after the user agrees, then confirms the new status.
## Limitations
- Exit code 137 means the process received SIGKILL; check OOMKilled before blaming memory.
- `docker stats` shows a single sample with `--no-stream`; it is not a trend.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A locally running API container keeps exiting and the developer wants to know why and get it running again.
My api container keeps dying. Find out why and restart it.
The agent runs `docker version` and `docker context show` first. If the daemon is unreachable it stops and says so. Otherwise `docker ps -a --filter name=api` finds the exact container (for example shop-api, Exited (137)), and `docker inspect shop-api --format ...` reports status, exit code and OOMKilled. `docker logs --tail 200 --timestamps shop-api` is summarised. The agent explains the likely cause from that evidence, then proposes `docker start shop-api`, or recreating it with a higher `--memory` limit if OOMKilled is true. It waits for a yes, runs the command, and shows the new `docker ps` status. Nothing is removed or pruned.
AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install Docker Container Manager by following these steps.
SKILL.md inside, in the location documented by your client. Do not assume every AI application reads the same directory.Requires an Agent Skills-compatible client; supported locations and activation vary by version. Read the SKILL.md setup guide. MCP connects tools and data and does not, by itself, install a skill.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts