Exploring Container Details
Viewing Container Details
To view detailed information about a Docker container, you can use the following commands:
docker inspect
: This command provides detailed information about a container, including its configuration, network settings, and runtime state.
## Example: Inspect a running container
docker inspect <container_id>
docker stats
: This command displays real-time performance statistics for one or more containers, such as CPU usage, memory usage, and network I/O.
## Example: View stats for all running containers
docker stats
docker top
: This command lists the running processes within a container.
## Example: List processes in a running container
docker top <container_id>
Docker containers have various metadata associated with them, which can be accessed using the docker inspect
command. Some of the key metadata fields include:
Field |
Description |
Id |
The unique identifier of the container. |
Image |
The Docker image used to create the container. |
Name |
The name of the container. |
State |
The current state of the container (e.g., running, stopped). |
NetworkSettings |
The network configuration of the container. |
Mounts |
The volumes or directories mounted inside the container. |
graph LR
A[Container Metadata] --> B[Id]
A --> C[Image]
A --> D[Name]
A --> E[State]
A --> F[NetworkSettings]
A --> G[Mounts]
Inspecting Container Logs
To view the logs of a Docker container, you can use the docker logs
command. This command allows you to access the standard output (stdout) and standard error (stderr) streams of a container.
## Example: View logs of a running container
docker logs <container_id>
By understanding and exploring the details of Docker containers, you can effectively manage and troubleshoot your containerized applications.