I'm having docker containers in Linux server, I need know how to get details of applications, services and its status inside the containers. Which command do I need to execute to get those details.
For example:
A container contains tomcat server. I need to get the details of tomcat server and its status(whether the service is running or not).
I don't know is there any command available to get those details.
you can use the docker exec command to execute any command you need inside the container.
For instance, to list all running processes inside a container:
docker exec <my container> ps aux
or to display the content of a file
docker exec <my container> cat /etc/resolv.conf
Those commands will be executed with the user defined in your image. You can override it with the -u option:
docker exec -u root <my container> ls -l
If you need to run multiple commands, or use environment variables that exists within the container, use the following trick:
docker exec <my container> sh -c 'echo ~; echo "PATH: $PATH"'
LIST all containers:
docker stats $(docker ps|grep -v "NAMES"|awk '{ print $NF }'|tr "\n" " ") --no-stream
LIST containers with memory usage more than 99%:
docker stats $(docker ps|grep -v "NAMES"|awk '{ print $NF }'|tr "\n" " ") --no-stream | sort -k 8n | awk '(NR>1) && ($8 > 99 ) '
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With