Docker CLI
$ docker Official Med RiskDocker CLI (docker) builds, inspects, and runs containers, images, volumes, and Compose stacks, offering --format json (and Go template projections) across ps, images, inspect, and compose ls, plus --context endpoint isolation.
brew install docker docker is universally pretrained across LLMs and provides native --format json and Go-template projection directly on local sockets.
Agent-Readiness Checklist
Local Probe EvidenceCaptured --help excerpt
Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Common Commands: run Create and run a new container from an image exec Execute a command in a running container ps List containers build Build an image from a Dockerfile pull Download an image from a registry push Upload an image to a registry images List images login Authenticate to a registry logout Log out from a registry search Search Docker Hub for images version Show the Docker version information info Display system-wide information Management Commands: builder Manage builds checkpoint Manage checkpoints container Manage containers context Manage contexts image Manage images manifest Manage Docker image manifests and manifest lists network Manage networks plugin Manage plugins system Manage Docker volume Manage volumes Swarm Commands: config Manage Swarm configs node Manage Swarm nodes secret Manage Swarm secrets service Manage Swarm services stack Manage Swarm stacks swarm Manage Swarm Commands: attach Attach local standard input, output, and error streams to a running container commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server export Export a container's filesystem as a tar archive history Show the history of an image import Import the contents from a tarball to create a filesystem image inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images save Save one or more images to a tar archive (streamed to STDOUT by default) start Start one or more stopped containers stats Display a live stream of container(s) resource usage s
FCRS-1.0 6-Dimension Breakdown
--format json and Go template expressions ({{json .Field}}) work across nearly all list/inspect subcommands.
- Universal
--format jsonand Go template projection
--context isolates local vs remote daemons cleanly, though root-equivalent Docker socket access and system prune require strict caution.
- Supports
--contextisolation; socket access carries host privileges
Single Go CLI binary available everywhere, though runtime actions require a running Docker Engine or compatible daemon.
- Available on macOS, Linux, and Windows
Covers image builds, containers, networks, and docker compose in one ubiquitous tool.
- Full container and Compose lifecycle in one CLI
Official docker/cli maintained continuously by Docker Inc.
- Official
docker/cliunder Apache-2.0
Exhaustive official CLI reference and consistent --help output.
- Complete reference at docs.docker.com
Security, Auth & Guardrails
Stores registry auth and credential helper settings in ~/.docker/config.json (plus OS keychain), and honors DOCKER_HOST / DOCKER_CONTEXT.
Docker CLI is open-source (Apache-2.0); Docker Desktop has commercial licensing tiers for larger enterprises.
# Docker CLI Agent Rules
- Always pass `--format json` (or `--format '{{json .}}'`) on `ps`, `images`, `network ls`, and `inspect`.
- Verify `docker context show` before targeting remote daemons.
- Never run `docker system prune -af` or `docker volume rm` without explicit user approval. Agent-Ready Command Recipes
Safe Read-Only Queries
docker ps --format json --no-trunc
Outputs newline-delimited JSON objects for each active container.
docker inspect my-container --format '{{json .State}}' Projects only the .State object via Go templates instead of dumping the full manifest.
Controlled Writes & Previews
docker compose config --quiet
Parses and validates compose.yaml interpolation and syntax locally.
Strengths for Agents
- +
--format jsonand Go templates (--format '{{json .State}}') trim output natively. - + Deep LLM pretraining familiarity across Docker and
docker compose. - + Fast Go client binary with clean
--contextswitching.
Caveats & Pitfalls
- !
docker ps --format jsonemits NDJSON (one JSON object per line), not a single JSON array. - ! Access to the Docker daemon socket is effectively root-equivalent on the host.