CLI Tools For Managing Docker Containers
Table of contents
For a container to be properly managed, it should be monitored. Monitoring containers help with information needed on the overall performance of the containers and the applications running in them.
Containers operate in a complex architecture which makes them more sensitive than conventional applications running on physical and virtual servers.
Ever wondered what is going on inside a running container? The number of resources being consumed? What are the processes running inside the containers and the number of logs being generated?
Though there are some enterprise programs specifically designed to monitor and manage containers, the CLI tools are also best suited as they always come in handy when basic health checks on containers are to be carried out.
Some Command Line Monitoring Tools
Docker Container Top
The top tool generally in Linux is used to monitor processes by listing them one after another to enable users to identify the number of processes running inside their container.
Using top tool
Start a container
Copy the container ID or name
Parse the container ID or name in the command
$ docker top <container id or name>
. This would show how many processes are running, and a detail of each of these processes including the user, user ID, process ID, timestamp, CMD, etc.
- Docker container inspect
The inspect tool is used to serve the full details of a container configuration in a JSON format. The output is usually lengthy stressing key values and providing information about the network, the container ID, the IP address, the image ID, the status, timestamp. $ docker inspect <container name or ID>
- Docker container stats
The stat tool is used to view the current status and performance of a running container along with other information such as CPU consumption, memory usage and limit, process ID, etc. $ docker container stats <container ID>
- Docker container logs
Logging keeps a tab on events and information such as warnings and failures about containers following the Docker system; these logs allow one to find out about issues with an application and diagnose them. $ docker container logs <container name or ID>
More on the command line monitoring and management in docker, the docker help tool gives a full list $ docker --help