19.3.3 Version CLI Command
A focused guide to Version CLI Command, connecting core concepts with practical Docker and container operations.
docker version displays version information for both the Docker client and the Docker server (daemon). It is the primary command for verifying which version of Docker is installed and confirming that the client and server are communicating correctly. If the server section of the output is missing or shows an error, it indicates that the Docker daemon is not running or the client cannot connect to it.
Running the Command
docker version
Default Output
The output is divided into two sections:
Client: Docker Engine - Community
Version: 25.0.3
API version: 1.44
Go version: go1.21.6
Git commit: 4debf41
Built: Tue Feb 6 21:12:32 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 25.0.3
API version: 1.44 (minimum version 1.12)
Go version: go1.21.6
Git commit: 4debf41
Built: Tue Feb 6 21:12:32 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.13
GitCommit: 7c3aca7a610df76212171d200ca3811ff6096eb8
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e946
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Client Section
The Client section describes the Docker CLI binary installed on the local machine:
- Version: The Docker CLI version number. This follows semantic versioning.
- API version: The highest Docker API version the client supports. The client uses this version when communicating with the daemon unless the daemon supports a lower maximum.
- Go version: The version of the Go compiler used to build the client binary.
- Git commit: The short commit hash of the source code from which the client was built.
- Built: The timestamp when the client binary was compiled.
- OS/Arch: The operating system and CPU architecture for which the client was compiled. Common values are
linux/amd64,darwin/arm64(Apple Silicon Macs), andwindows/amd64. - Context: The Docker context currently in use. The
defaultcontext connects to the local Docker daemon. Named contexts connect to remote daemons or Docker Desktop virtual machines.
Server Section
The Server section describes the Docker daemon running on the host:
Engine
- Version: The Docker Engine (daemon) version number.
- API version: The highest and lowest API versions the daemon supports. The format
1.44 (minimum version 1.12)means the daemon supports clients using API versions from 1.12 through 1.44. - Go version: The Go compiler version used to build the daemon.
- Git commit: The short commit hash of the daemon's source code.
- Built: When the daemon binary was compiled.
- OS/Arch: The OS and architecture where the daemon is running.
- Experimental: Whether experimental Docker features are enabled on the daemon.
containerd
containerd is the container runtime that Docker Engine delegates to for managing container lifecycle operations. The version shown here is the containerd binary bundled with or installed alongside Docker Engine.
runc
runc is the OCI-compliant container runtime that containerd uses to actually create and run containers. It interacts directly with Linux kernel features (namespaces, cgroups, seccomp). The runc version affects container security and compatibility.
docker-init
docker-init is a minimal init process that Docker injects as PID 1 in containers started with the --init flag. It handles signal forwarding and zombie process reaping.
Checking Connectivity
If the daemon is not running or the client cannot connect, the Server section is replaced with an error:
Client: Docker Engine - Community
Version: 25.0.3
...
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
This message confirms the client binary works but the daemon is unreachable.
Using --format
The --format flag accepts a Go template to extract specific fields:
docker version --format "{{.Server.Version}}"
docker version --format "{{.Client.Version}}"
docker version --format "{{.Server.Os}}/{{.Server.Arch}}"
These are useful in scripts that need to check version compatibility or gate behavior based on the installed Docker version.
Using -f (Short Flag)
-f is the short form of --format:
docker version -f "{{.Server.APIVersion}}"
API Version Compatibility
The client and server negotiate the API version to use. If the client's maximum API version is higher than the server's maximum, the client downgrades to the server's maximum. If the server's minimum API version is higher than what the client supports, operations may fail.
The API version mismatch error looks like:
Error response from daemon: client version 1.40 is too old. Minimum supported API version is 1.41.
Updating Docker resolves this by aligning the client and server API version ranges.
Practical Use Cases
Verifying Docker is installed correctly:
docker version
Both the Client and Server sections appearing without errors confirms Docker is functional.
Checking the Docker version in a script:
SERVER_VERSION=$(docker version -f "{{.Server.Version}}")
echo "Docker server: $SERVER_VERSION"
Checking API version for compatibility:
docker version -f "{{.Server.APIVersion}}"
Confirming the daemon architecture on a remote context:
docker --context remote_host version -f "{{.Server.Os}}/{{.Server.Arch}}"