How can I view the resource statistics of the nginx container?

To view resource statistics for the nginx container, follow these steps:

  1. Access the container: You can enter the shell environment of the container using the docker exec command, for example: docker exec -it bash.
  2. Check the PID of the nginx process using the ps command: Within the shell environment of the container, run the command ps -ef | grep nginx to find the PID of the nginx process.
  3. Use the top command to view resource statistics for the nginx process: In the container’s shell environment, simply run the top -p command to monitor real-time usage of resources by the nginx process, including CPU and memory usage.
  4. To check the running status and statistics of nginx using nginx commands: in the container’s shell environment, running the command nginx -V displays the version and compilation parameters of nginx; running nginx -t tests the syntax of the nginx configuration file; running nginx -s status shows the running status and statistics of nginx.

Additionally, if you are running docker-compose on the host machine, you can use the docker-compose exec command to enter the container and follow the steps mentioned above.

bannerAds