Docker container commands – logs, inspect, top, stats

Inspect command

>> docker container inspect CONTAINER-ID

inspect command is used to display a detailed information on a single or multiple containers

Say we are running an Nginx container

>>  docker container run -d nginx

Note* The above container is running in the background. If we want detailed information about the above Nginx container like Date, Status, HostnamePath, Driver, PortBindings, Volume, etc then we can use a inspect command.

docker container inspect

logs command

>> docker container logs CONTAINER-ID

logs command is used to fetch the logs of a container

If we want to fetch logs of the above-created Nginx container then we can use the logs command.

top command

>> docker container top CONTAINER-ID

top command display the running processes of a container

If we want to display the running process of the above-created Nginx container then we can use the top command.

stats command

>> docker container stats CONTAINER-ID

It displays how much resources is been used by a container

If we want to display the stats of the above-created Nginx container then we can use the stats command.

docker container stats

In this article, we have covered docker container commands to inspect the container, to fetch the logs of the container, to display the running process of the container, to display the stats of the container along with examples. I hope you found this article interesting and valuable. Please share this article with your friends and help me grow. If you are having any concerns or questions about this article please comment below. If you want to get in touch with me please visit the Contact Me page and send me an email.

1 thought on “Docker container commands – logs, inspect, top, stats”

Leave a Comment