# docker/cli architecture

> Architecture diagram of the GitHub repository docker/cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/docker/cli
- Repository: https://github.com/docker/cli

## Overview

Docker CLI is the user-facing command-line client for Docker Engine and related services. Users invoke `docker` commands to manage containers, images, networks, volumes, Swarm services and stacks; command handlers use the configured client and render results to terminal streams. Compose files are loaded and converted for stack deployment, while registry operations handle image distribution and authentication. The repository also provides CLI-plugin discovery/execution and a standalone image-trust command. The graph follows documented capabilities and paths in the tree; several command-to-client details are inferred from the command roles because their implementations were not sampled.

Main entry points: [`cli/command/cli.go`](https://github.com/docker/cli/blob/master/cli/command/cli.go) (Command framework), [`cmd/docker/docker.go`](https://github.com/docker/cli/blob/master/cmd/docker/docker.go) (Docker executable), [`cli/command/stack`](https://github.com/docker/cli/tree/master/cli/command/stack) (Stack commands), [`internal/registryclient/client.go`](https://github.com/docker/cli/blob/master/internal/registryclient/client.go) (Registry client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_docker["Docker executable<br/>[docker.go]"]
  node_command["Command framework<br/>[cli.go]"]
  node_contexts[("Contexts and config<br/>[store.go]")]
end

subgraph group_resources["Engine resources"]
  node_container["Container commands"]
  node_network["Network commands"]
  node_volume["Volume commands"]
  node_system["System commands"]
end

subgraph group_orchestration["Orchestration"]
  node_stack["Stack commands"]
  node_compose["Compose loading<br/>[loader.go]"]
  node_conversion["Swarm conversion<br/>[service.go]"]
  node_service["Service commands"]
  node_swarm["Swarm commands"]
end

subgraph group_distribution["Images and auth"]
  node_image["Image commands"]
  node_registry["Registry client<br/>[client.go]"]
  node_registryauth["Registry authentication<br/>[service.go]"]
  node_oauth["OAuth login<br/>[manager.go]"]
  node_manifest["Manifest commands"]
end

subgraph group_extensions["Extensions"]
  node_pluginmanager["Plugin manager<br/>[manager.go]"]
  node_plugin["Plugin runtime<br/>[plugin.go]"]
  node_trust["Image trust CLI"]
end

node_user(("Docker user"))
node_engine["Docker Engine"]

node_user -->|"runs commands"| node_docker
node_docker -->|"initializes"| node_command
node_command -->|"loads configuration"| node_contexts
node_command -->|"dispatches"| node_container
node_command -->|"dispatches"| node_image
node_command -->|"dispatches"| node_network
node_command -->|"dispatches"| node_volume
node_command -->|"dispatches"| node_system
node_command -->|"dispatches"| node_stack
node_command -->|"dispatches"| node_service
node_command -->|"dispatches"| node_swarm
node_command -->|"dispatches"| node_manifest
node_container -->|"calls Engine API"| node_engine
node_network -->|"calls Engine API"| node_engine
node_volume -->|"calls Engine API"| node_engine
node_system -->|"calls Engine API"| node_engine
node_service -->|"calls Engine API"| node_engine
node_swarm -->|"calls Engine API"| node_engine
node_stack -->|"queries cluster"| node_engine
node_stack -->|"loads Compose files"| node_compose
node_stack -->|"converts services"| node_conversion
node_image -->|"calls Engine API"| node_engine
node_image -->|"transfers images"| node_registry
node_manifest -->|"reads and writes"| node_registry
node_registry -->|"resolves credentials"| node_registryauth
node_registry -.->|"separate API client"| node_engine
node_command -->|"authenticates"| node_registryauth
node_command -.->|"device login"| node_oauth
node_docker -->|"discovers plugins"| node_pluginmanager
node_pluginmanager -->|"executes plugin"| node_plugin
node_docker -->|"standalone or plugin"| node_trust

click node_docker "https://github.com/docker/cli/blob/master/cmd/docker/docker.go"
click node_command "https://github.com/docker/cli/blob/master/cli/command/cli.go"
click node_contexts "https://github.com/docker/cli/blob/master/cli/context/store/store.go"
click node_container "https://github.com/docker/cli/tree/master/cli/command/container"
click node_network "https://github.com/docker/cli/tree/master/cli/command/network"
click node_volume "https://github.com/docker/cli/tree/master/cli/command/volume"
click node_system "https://github.com/docker/cli/tree/master/cli/command/system"
click node_image "https://github.com/docker/cli/tree/master/cli/command/image"
click node_registry "https://github.com/docker/cli/blob/master/internal/registryclient/client.go"
click node_registryauth "https://github.com/docker/cli/blob/master/internal/registry/service.go"
click node_oauth "https://github.com/docker/cli/blob/master/internal/oauth/manager/manager.go"
click node_manifest "https://github.com/docker/cli/tree/master/cli/command/manifest"
click node_stack "https://github.com/docker/cli/tree/master/cli/command/stack"
click node_compose "https://github.com/docker/cli/blob/master/cli/compose/loader/loader.go"
click node_conversion "https://github.com/docker/cli/blob/master/cli/compose/convert/service.go"
click node_service "https://github.com/docker/cli/tree/master/cli/command/service"
click node_swarm "https://github.com/docker/cli/tree/master/cli/command/swarm"
click node_pluginmanager "https://github.com/docker/cli/blob/master/cli-plugins/manager/manager.go"
click node_plugin "https://github.com/docker/cli/blob/master/cli-plugins/plugin/plugin.go"
click node_trust "https://github.com/docker/cli/tree/master/cmd/docker-trust/trust"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_docker,node_command,node_contexts,node_user toneBlue
class node_container,node_network,node_volume,node_system toneAmber
class node_stack,node_compose,node_conversion,node_service,node_swarm toneMint
class node_image,node_registry,node_registryauth,node_oauth,node_manifest toneRose
class node_pluginmanager,node_plugin,node_trust,node_engine toneIndigo
```

## Components

### CLI entry

- [Docker executable](https://github.com/docker/cli/blob/master/cmd/docker/docker.go): `cmd/docker/docker.go`
- [Command framework](https://github.com/docker/cli/blob/master/cli/command/cli.go): `cli/command/cli.go`
- [Contexts and config](https://github.com/docker/cli/blob/master/cli/context/store/store.go): `cli/context/store/store.go`

### Engine resources

- [Container commands](https://github.com/docker/cli/tree/master/cli/command/container): `cli/command/container`
- [Network commands](https://github.com/docker/cli/tree/master/cli/command/network): `cli/command/network`
- [Volume commands](https://github.com/docker/cli/tree/master/cli/command/volume): `cli/command/volume`
- [System commands](https://github.com/docker/cli/tree/master/cli/command/system): `cli/command/system`

### Orchestration

- [Stack commands](https://github.com/docker/cli/tree/master/cli/command/stack): `cli/command/stack`
- [Compose loading](https://github.com/docker/cli/blob/master/cli/compose/loader/loader.go): `cli/compose/loader/loader.go`
- [Swarm conversion](https://github.com/docker/cli/blob/master/cli/compose/convert/service.go): `cli/compose/convert/service.go`
- [Service commands](https://github.com/docker/cli/tree/master/cli/command/service): `cli/command/service`
- [Swarm commands](https://github.com/docker/cli/tree/master/cli/command/swarm): `cli/command/swarm`

### Images and auth

- [Image commands](https://github.com/docker/cli/tree/master/cli/command/image): `cli/command/image`
- [Registry client](https://github.com/docker/cli/blob/master/internal/registryclient/client.go): `internal/registryclient/client.go`
- [Registry authentication](https://github.com/docker/cli/blob/master/internal/registry/service.go): `internal/registry/service.go`
- [OAuth login](https://github.com/docker/cli/blob/master/internal/oauth/manager/manager.go): `internal/oauth/manager/manager.go`
- [Manifest commands](https://github.com/docker/cli/tree/master/cli/command/manifest): `cli/command/manifest`

### Extensions

- [Plugin manager](https://github.com/docker/cli/blob/master/cli-plugins/manager/manager.go): `cli-plugins/manager/manager.go`
- [Plugin runtime](https://github.com/docker/cli/blob/master/cli-plugins/plugin/plugin.go): `cli-plugins/plugin/plugin.go`
- [Image trust CLI](https://github.com/docker/cli/tree/master/cmd/docker-trust/trust): `cmd/docker-trust/trust`

### Other components

- **Docker user**
- **Docker Engine**

## Connections

- Docker user → Docker executable: runs commands
- Docker executable → Command framework: initializes
- Command framework → Contexts and config: loads configuration
- Command framework → Container commands: dispatches
- Command framework → Image commands: dispatches
- Command framework → Network commands: dispatches
- Command framework → Volume commands: dispatches
- Command framework → System commands: dispatches
- Command framework → Stack commands: dispatches
- Command framework → Service commands: dispatches
- Command framework → Swarm commands: dispatches
- Command framework → Manifest commands: dispatches
- Container commands → Docker Engine: calls Engine API
- Network commands → Docker Engine: calls Engine API
- Volume commands → Docker Engine: calls Engine API
- System commands → Docker Engine: calls Engine API
- Service commands → Docker Engine: calls Engine API
- Swarm commands → Docker Engine: calls Engine API
- Stack commands → Docker Engine: queries cluster
- Stack commands → Compose loading: loads Compose files
- Stack commands → Swarm conversion: converts services
- Image commands → Docker Engine: calls Engine API
- Image commands → Registry client: transfers images
- Manifest commands → Registry client: reads and writes
- Registry client → Registry authentication: resolves credentials
- Registry client → Docker Engine: separate API client
- Command framework → Registry authentication: authenticates
- Command framework → OAuth login: device login
- Docker executable → Plugin manager: discovers plugins
- Plugin manager → Plugin runtime: executes plugin
- Docker executable → Image trust CLI: standalone or plugin
