This post will cover topic related to ‘Managing Docker System’ with multiple docker command examples and different scenerios. So this will help you to understand the command docker and options available in it. Also this post will explain you how to use docker command.
Docker is a powerful tool for containerization, allowing developers to package applications and their dependencies into lightweight, portable containers. One essential aspect of Docker management is handling Docker system operations, which include tasks like managing containers, images, volumes, networks, and other resources crucial for running Dockerized applications efficiently.
Example 1: Listing Docker System Information
To view detailed information about Docker system, including containers, images, and storage usage, use the command: docker system df
. This command displays disk usage related to Docker.
OUTPUT: TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 3 1 1.234GB 678.9MB (55%) Containers 4 2 567.8MB 123.4MB (21%) Local Volumes 7 6 2.345GB 1.789GB (76%)
To verify execution, check the displayed summary of Docker storage usage metrics.
Example 2: Pruning Unused Docker Resources
To free up disk space by removing unused Docker resources such as stopped containers, dangling images, and unused networks, use: docker system prune
. This command prompts for confirmation before deleting unused data.
OUTPUT: Deleted Containers: 1a2b3c4d5e6f 7g8h9i0j1k2l Total reclaimed space: 456.7MB
Verify by observing the list of deleted containers and the amount of space reclaimed after execution.
Example 3: Checking Docker Version Information
To display Docker version and detailed information about client and server components, use: docker version
.
OUTPUT: Client: Version: 20.10.7 API version: 1.41 Go version: go1.16.5 Git commit: abcdef1 Server: Engine: Version: 20.10.7 API version: 1.41 (minimum version 1.12) Go version: go1.16.5 Git commit: abcdef1 Containerd: Version: 1.4.6
To verify, compare the displayed version and configuration details with your Docker installation.
Example 4: Displaying Docker System Events
To monitor Docker system events in real-time, use: docker system events
. This command continuously streams events like container creation, deletion, and more.
OUTPUT: 2024-07-08T12:34:56.789123456Z container create 1a2b3c4d5e6f7g8h 2024-07-08T12:35:00.123456789Z container destroy 1a2b3c4d5e6f7g8h
Verification involves observing the streaming events related to Docker system operations.
Example 5: Displaying Docker System Information (Detailed)
For a detailed overview of Docker system information, use: docker system info
. This command provides comprehensive details about Docker and its components.
OUTPUT: Containers: 4 Running: 2 Paused: 1 Stopped: 1 Images: 6 Server Version: 20.10.7 Storage Driver: overlay2
To verify, review the detailed system information displayed, including container and image counts.
Also check similar articles.
Managing Docker Plugins
Managing Docker Image Manifests and Lists
Managing Docker Images
Managing Docker Contexts
Managing Docker Containers
Discussion about this post