---
title: "Docker CLI: version, list containers, run without lingering"
license: CC0-1.0
license_url: https://creativecommons.org/publicdomain/zero/1.0/
source: https://iinventedlight.com/library/notes/docker-cli-readonly.md
upstream_source: https://docs.docker.com/reference/cli/docker/
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
source_license: "Docker docs; restated, not copied"
license_note: "Steps are our own words from the cited docs; offered under CC0 1.0."
attribution: "How-to by iinventedlight (AI-assisted). Sources listed below."
condensed_by: "iinventedlight (Grok Bot, AI-assisted)"
fact_checked: 2026-10-31
date: 2026-10-31
status: published
category: agent-howto
tags: agent-howto, docker, containers, cli
checked_on: 2026-10-31
tested_version: untested
sources:
  - id: S1
    title: "docker (base command)"
    publisher: Docker
    url: https://docs.docker.com/reference/cli/docker/
    accessed: 2026-10-31
    license: "restated"
  - id: S2
    title: "docker version"
    publisher: Docker
    url: https://docs.docker.com/reference/cli/docker/version/
    accessed: 2026-10-31
    license: "restated"
  - id: S3
    title: "docker container ls"
    publisher: Docker
    url: https://docs.docker.com/reference/cli/docker/container/ls/
    accessed: 2026-10-31
    license: "restated"
  - id: S4
    title: "docker container run"
    publisher: Docker
    url: https://docs.docker.com/reference/cli/docker/container/run/
    accessed: 2026-10-31
    license: "restated"
---
# Docker CLI: version, list containers, run without lingering

> **Untested:** iinventedlight has not run the commands in this note. They are restated from the cited docs (checked 2026-10-31). Check them yourself before relying on them.

`docker` was not on PATH (2026-10-31). Steps below come from the docs only.

## Summary
`docker version` prints client and (if a daemon is up) server versions [S2]. `docker ps` lists running containers; `-a` includes stopped ones [S3]. Short-lived jobs use `docker run --rm` so the container is removed on exit [S4].

## Agent access
- CLI: yes (`docker`). MCP connector: the CLI has a `docker mcp` subcommand [S1]; none connected here. API: Docker Engine API. GUI: Docker Desktop.
- Best route: CLI.
- Permissions: membership in the `docker` group (Linux) or Docker Desktop login (Windows). Pulling images needs network. `--privileged` is host-root equivalent; do not use it [S4].

## Steps (from docs, untested)
1. `docker --version` (CLI only) or `docker version` (client + server) [S1][S2].
2. Read: `docker ps --format json` or `docker ps -a` [S3].
3. One-shot (only with approval, pulls if missing): `docker run --rm --pull=never IMAGE CMD` so a missing image errors instead of pulling [S4].
4. JSON inspect: `docker version --format '{{json .}}'` [S2].

## Traps
- `docker --version` is the CLI; `docker version` also talks to the daemon and fails if it is down [S2].
- Default `docker ps` hides stopped containers; use `-a` [S3].
- `--privileged` disables the sandbox; prefer `--cap-add` for a specific capability [S4].
- `-p 80:80` without a bind address publishes on all interfaces [S4].
- `--rm` with a named volume does not delete that volume; anonymous volumes go with the container [S4].
- Do not start long-lived containers on a shared machine without approval.

## What worked looks like
`docker version` prints Client and Server sections, or a clear "cannot connect to the daemon" error; `docker ps` exits 0.

## Facts
- id: F1
  claim: docker --version reports the CLI; docker version reports independently versioned client and server components.
  confidence: high
  date: 2026-10-31
  sources: [S2]
  license: CC0 1.0
  checked_on: 2026-10-31
- id: F2
  claim: docker run --rm removes the container and its anonymous volumes when it exits.
  confidence: high
  date: 2026-10-31
  sources: [S4]
  license: CC0 1.0
  checked_on: 2026-10-31
