Selected topic
Monitoring And Logging
Prefer practical output? Use related tools below while reading.
docker stats command is used to display real-time statistics about running containers.Here are some key statistics provided by docker stats:
bash
docker run -d --name my-container ubuntu:latest /bin/bash -c "while true; do echo Hello World! >> /dev/null; done"# Run docker stats to view container statistics
docker stats my-container
CONTAINER ID NAME CPU % MEM USAGE/LIMIT MEM % NET I/O BLOCK I/O
f0d65... my-container 0.00% 15.4M of 500M 3.05% 23.1kB / 21.9kB 10.2kB / 5.33kB
docker stats command displays real-time statistics about the container named my-container. The output shows that the container is using approximately 15.4MB of memory out of a total available 500MB (3.05% utilization), and has performed some network I/O.docker logs command can be used to view the output of container processes, including standard output, standard error, and any other output generated by the container.bash
docker run -d --name my-container ubuntu:latest /bin/bash -c "while true; do echo Hello World! >> /dev/null; done"# Run docker logs to view container output
docker logs my-container
Hello World!
# View container events using the docker events command
docker events --since 1m
docker logs command is used to view the output of the container named my-container. The output shows that the container has executed a while loop that outputs "Hello World!" repeatedly. The docker events command is then used to capture and display container lifecycle events over the past minute.Note: Docker also provides other features such as Container isolation, Resource Management, Networking, etc., which are not covered in this summary.