The 'docker system' command serves as a gateway to various subcommands that provide insights and control over Docker's system resources. It offers a unified interface to manage Docker's disk usage, prune unused data, inspect resource utilization, and more. Let's explore some of the key subcommands and their applications.
1. Overview of Docker System:
The docker system command provides valuable insights into various aspects of Docker resources, including images, containers, volumes, and build cache. Running docker system df displays a summary of resource utilization, categorized into different types and their reclaimable space.
[root@siddhesh ~]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 3 0 487.6MB 487.6MB (100%)
Containers 0 0 0B 0B
Local Volumes 1 0 41.7MB 41.7MB (100%)
Build Cache 0 0 0B 0B
[root@siddhesh ~]#
In the provided output:
Images: There are a total of 3 Docker images present on the system, with a total size of 487.6MB. All of this space is reclaimable, meaning none of these images are currently being used.
Containers: There are no Docker containers currently active or present on the system, hence the total and reclaimable sizes are both 0B.
Local Volumes: There is 1 local volume present on the system, occupying a total size of 41.7MB. Again, all of this space is reclaimable, indicating that the volume is not actively in use.
Build Cache: There are no entries in the build cache, indicating that there are no cached build layers present on the system.
2. Cleaning up Docker Resources:
Over time, Docker accumulates unused resources, leading to bloating and inefficiencies. The docker system prune command offers a solution by removing stopped containers, unused networks, dangling images, and building cache. This helps reclaim valuable disk space and ensures a lean Docker environment.
[root@siddhesh ~]# docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache
Are you sure you want to continue? [y/N] y
Deleted Networks:
docker_gwbridge
Total reclaimed space: 0B
[root@siddhesh ~]#
3. Docker System Events:
Monitoring Docker system events is crucial for tracking changes and activities within the Docker environment. The docker system events command provides real-time insights into container lifecycle events, image pulls, network changes, and more. Monitoring these events helps in troubleshooting, performance tuning, and maintaining system integrity.
[root@siddhesh ~]# docker system events
2024-02-18T17:13:53.662164131+05:30 image pull nginx:latest (maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>, name=nginx)
2024-02-18T17:13:54.423704105+05:30 container create 24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be (image=nginx, maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>, name=hardcore_williams)
2024-02-18T17:13:54.489193216+05:30 network connect ba109f36a23db5c326a4ecfc0dc51f02b96b16141e953ec529ac29487a2bdff9 (container=24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be, name=bridge, type=bridge)
2024-02-18T17:13:55.317268974+05:30 container start 24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be (image=nginx, maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>, name=hardcore_williams)
Let's break down each line of the output:
2024-02-18T17:13:53.662164131+05:30 image pull nginx:latest (maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>, name=nginx)
This line indicates that an image pull event occurred at the timestamp '2024-02-18T17:13:53.662164131+05:30'. Docker pulled the 'nginx:latest' image from the repository. Additionally, it provides metadata such as the image maintainer ('NGINX Docker Maintainers docker-maint@nginx.com') and the image name ('nginx').
2024-02-18T17:13:54.423704105+05:30 container create 24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be (image=nginx, maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>, name=hardcore_williams)
This line indicates that a container creation event occurred at the timestamp '2024-02-18T17:13:54.423704105+05:30'. Docker created a container with the ID '24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be' using the 'nginx' image. Metadata such as the image maintainer and the container name ('hardcore_williams') is also provided.
2024-02-18T17:13:54.489193216+05:30 network connect ba109f36a23db5c326a4ecfc0dc51f02b96b16141e953ec529ac29487a2bdff9 (container=24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be, name=bridge, type=bridge)
This line indicates that a network connection event occurred at the timestamp '2024-02-18T17:13:54.489193216+05:30'. Docker connected a container with the ID '24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be' to the bridge network.
2024-02-18T17:13:55.317268974+05:30 container start 24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be (image=nginx, maintainer=NGINX Docker Maintainers <docker-maint@nginx.com>, name=hardcore_williams)
This line indicates that a container start event occurred at the timestamp '2024-02-18T17:13:55.317268974+05:30'. Docker started the container with the ID '24cab485151dac57051d08ff1de270d01dc1c71d4677c4c6b4ca628d935996be', which was created using the 'nginx' image. Metadata such as the image maintainer and the container name ('hardcore_williams') is also provided.
4. Docker System Information:
Understanding the configuration and environment of the Docker host is essential for effective management. The docker system info command displays detailed information about the Docker client and server, including version, containers, images, and server configuration. This information aids in troubleshooting issues and optimizing Docker performance.
[root@siddhesh ~]# docker system info
Client: Docker Engine - Community
Version: 24.0.7
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.11.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.21.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 4
Server Version: 24.0.7
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
<OUTPUT TRUCATED>
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
[root@siddhesh ~]#
Comments