Docker Tutorial — Docker CLI Basics
The Docker CLI is your primary interface to Docker. Understanding its structure helps you work efficiently and discover commands.
CLI Structure
Docker uses a two-level command structure:
docker <object> <command> [options] [arguments]
| Object | Example Commands |
|---|---|
container |
docker container ls, docker container run, docker container rm |
image |
docker image ls, docker image pull, docker image rm |
volume |
docker volume ls, docker volume create |
network |
docker network ls, docker network create |
Essential First Commands
docker version
$ docker version
Client:
Version: 24.0.7
API version: 1.43
OS/Arch: linux/amd64
Server: Docker Engine - Community
Engine:
Version: 24.0.7
API version: 1.43
docker info
$ docker info
# Shows: number of containers, images, storage driver, kernel version, etc.
docker help
$ docker --help # List all commands
$ docker container --help # List container sub-commands
$ docker run --help # Help for a specific command
Legacy vs Management Commands
Docker kept old commands working for backward compatibility:
| Legacy Command | Management Command | Both Work |
|---|---|---|
docker ps |
docker container ls |
✅ |
docker images |
docker image ls |
✅ |
docker run |
docker container run |
✅ |
docker rmi |
docker image rm |
✅ |
Use whichever you prefer. Management commands are more explicit and discoverable.
Quick Reference
docker version → client and server version
docker info → system-wide configuration
docker --help → list all commands
docker <cmd> --help → help for specific command
Structure: docker <object> <command> [options]