Show Docker Disk Usage:
docker system df
Expected Output:
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 5 3 1.2GB 769.6MB (64%)
Containers 3 1 1.8GB 1.2GB (68%)
Local Volumes 2 1 1.1GB 586.4MB (52%)
Build Cache 0 0 0B 0B
This command shows disk usage related to Docker images, containers, local volumes, and build cache.
2. Prune Unused Resources:
docker system prune
Expected Output:
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all build cache
Are you sure you want to continue? [y/N]
This command removes stopped containers, networks not used by any container, dangling images, and build cache.
3. Display Docker System Events:
docker events
Expected Output:
2023-11-26T10:00:00.000000000Z container start 1234567890abcdef
2023-11-26T10:05:00.000000000Z image pull alpine:latest
This command displays real-time events from the Docker daemon, such as container starts, image pulls, etc.
4. Show Docker Version and Info:
docker version
docker info
Expected Output (version):
Client: Docker Engine - Community
Version: 20.10.6
Expected Output (info):
Client:
Context: default
Debug Mode: false
Server:
Containers: 3
Running: 1
Paused: 0
These commands show information about the Docker client and server versions, as well as various system details.
5. Display Docker System Prune Options:
docker system prune --help
Expected Output:
Usage: docker system prune [OPTIONS]
Remove unused data
Options:
-a, --all Remove all unused images not just dangling ones
--filter filter Provide filter values (e.g. 'label=<key>=<value>')
-f, --force Do not prompt for confirmation
-h, --help Print usage
-v, --volumes Prune volumes
This command shows options available for the docker system prune command.
6. Display System-wide Information:
docker system info
Expected Output:
Containers: 3
Running: 1
Paused: 0
This command shows detailed information about the Docker system, including container and resource usage.
7. Display Information about Docker Networks:
docker network ls
docker network inspect bridge
Expected Output (network ls):
NETWORK ID NAME DRIVER SCOPE
1234567890ab bridge bridge local
Expected Output (network inspect):
[ { "Name": "bridge", "Id": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "Created": "2023-11-26T10:00:00.000000000Z", "Scope": "local", ... }]
These commands show information about Docker networks, including a list of networks and detailed inspection of a specific network.
8. Display Low-level Information about Docker Objects:
docker inspect mycontainer
docker inspect myimage:1.0
docker inspect myvolume
Expected Output (container inspect):
[ { "Id": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "Created": "2023-11-26T10:00:00.000000000Z", "Path": "/bin/sh", ... }]
Expected Output (image inspect):
[ { "Id": "sha256:abcdef123456abcdef123456abcdef1234567890abcdef1234567890abcdef1234", "Created": "2023-11-26T10:00:00.000000000Z", "Os": "linux", ... }]
Expected Output (volume inspect):
[ { "Name": "myvolume", "Driver": "local", "Mountpoint": "/var/lib/docker/volumes/myvolume/_data", ... }]
These commands provide detailed information about specific Docker objects, including containers, images, and volumes.
9. Display Current Resource Usage:
docker stats mycontainer
Expected Output:
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
1234567890ab mycontainer 0.50% 200MiB / 1GiB 20.00% 2.34kB / 3.78kB 1.23MB / 2.34MB 2
This command shows real-time resource usage statistics for a specific container.
These Docker system and info commands cover a range of system-related tasks, from displaying disk usage to inspecting specific Docker objects and providing general information about the Docker environment. Adjust
Top comments (0)