CodeBlanks Logo Icon CodeBlanks

docker version

Learn to verify installation with docker version.

docker version

docker version shows the version of both the client (CLI) and the server (Engine). If the server section is missing or it says "Cannot connect to the Docker daemon", the daemon isn't running:

$ docker version
Client: Docker Engine - Community
 Version:    27.3.1
Server: Docker Engine - Community
 Engine:
  Version:   27.3.1

For short output, docker --version prints only the client version on one line.

Formatted output

Most Docker commands accept a Go template with --format. It is used in scripts to get only the needed field:

$ docker version --format '{{.Server.Version}}'
27.3.1
$ sudo systemctl start docker     # start the daemon if it's down

The same method works for commands like docker ps and docker inspect.

Practice Query the versions

Write two commands that first print the short client version (docker --version), then only the server version with --format.

Starter code

terminal
# buraya yaz

Sample solution

terminal
docker --version
docker version --format '{{.Server.Version}}'

Expected output

Docker version 27.3.1, build ce12230
27.3.1

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does the "Cannot connect to the Docker daemon" error mean?

  • The daemon isn't running or there's no access to the socket Correct answer
  • The image wasn't found
  • There's no internet
  • The container crashed

Explanation: On Linux, the daemon is started with sudo systemctl start docker.

2 Print only the server version.

Question
docker version --format '{{.____.Version}}'
Answer
docker version --format '{{.Server.Version}}'

Explanation: .Server in the template selects the server information.

3 Match the commands.

Term Meaning
docker version Client and server version
docker --version One-line client version
--format Go template
systemctl start docker Starts the daemon

All lessons in Beginner