Docker View Process, Memory, and Cup Consumption

Docker View Process, Memory, and Cup Consumption

Docker view process, memory, cup consumption

Start the docker container and view the process number through docker inspect

# docker inspect -f '{{.State.Pid}}'

View memory and CPU usage through docker stats

docker stats
docker stats --no-stream
docker stats container-name
docker stats $(docker ps --format={{.Names}})
docker stats --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"
docker stats --no-stream --format "{\"container\":\"{{ .Container }}\",\"memory\":{\"raw\":\"{{ .MemUsage }}\",\"percent\":\"{{ .MemPerc }}\"},\"cpu\":\"{{ .CPUPerc }}\"}"

Here are all the placeholders you can use in your custom formats:

.Container Displays the name or ID of the container, depending on the name specified by the user.

.Name The container name.

.ID Container ID.

.CPUPerc CPU usage.

.MemUsage Memory usage.

.NetIO Network I/O.

.BlockIO disk I/O.

.MemPerc Memory usage.

.PIDs PID number.

Supplement: Docker view container running memory and delete commands

1. Docker usage of cpu, memory, network, and io

1.1、docker stats container id

node3:~# docker stats 7a20f9671dbd
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
7a20f9671dbd 0.09% 1.837GiB / 3.859GiB 47.61% 52.3MB / 28.7MB 3.32MB / 16.4kB 62

1.2, -a displays all containers (default displays just run)

node3:~# docker stats -a

CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
7a20f9671dbd 0.09% 1.837GiB / 3.859GiB 47.61% 52.4MB / 28.7MB 3.32MB / 16.4kB 62
4eeb00be3547 0.69% 34.3MiB / 3.859GiB 0.87% 0B / 0B 5.8MB / 0B 19
c52a162de8e8 0.23% 131MiB / 3.859GiB 3.32% 1.01GB / 860MB 3.25MB / 106kB 22
ff7ed47106ad 0.00% 11.98MiB / 3.859GiB 0.30% 0B / 0B 1.9MB / 11.3MB 9
33b6ad13d1dc 0.13% 3.48MiB / 3.859GiB 0.09% 800B / 0B 0B / 0B 8
06a1d01f5024 0.19% 6.973MiB / 3.859GiB 0.18% 0B / 0B 143kB / 5.37MB 23
5e03f86078fd 0.00% 15.06MiB / 3.859GiB 0.38% 0B / 0B 1.79MB / 4.1kB 13
c78ed69d6c66 0.01% 6.227MiB / 3.859GiB 0.16% 0B / 0B 0B / 0B 7

1.3. Display the running information of multiple containers

docker stats rId1,rId2

2. Docker delete command

2.1. Delete all stopped containers

docker rm $(docker ps -a -q)

2.2. Delete all untagged images

docker rmi $(docker images -q | awk '/^<none>/ { print $3 }')

2.3. Fuzzy deletion

docker images | grep registry.cn-qingdao.aliyuncs.com/duodianyouhui/dev-server | xargs docker rmi

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • Docker uses Supervisor to manage process operations
  • Dockerfile implementation code when starting two processes in a docker container
  • Detailed explanation of Docker daemon security configuration items
  • How to configure and operate the Docker daemon
  • A brief discussion on Docker client and daemon
  • Detailed explanation of Docker daemon configuration and logs
  • How to interact with the Docker command line and the daemon process
  • Understanding Docker isolation technology from the process

<<:  Analysis of several situations where MySQL index fails

>>:  Vue+video.js implements video playlist

Recommend

Detailed explanation of nginx installation, deployment and usage on Linux

Table of contents 1. Download 2. Deployment 3. Ng...

MySQL 5.7.21 installation and password configuration tutorial

MySQL5.7.21 installation and password setting tut...

Nginx access control and parameter tuning methods

Nginx global variables There are many global vari...

How to use watch listeners in Vue2 and Vue3

watch : listen for data changes (change events of...

Detailed tutorial on installing ElasticSearch 6.x in docker

First, pull the image (or just create a container...

Solution for Docker Swarm external verification load balancing not taking effect

Problem Description I created three virtual machi...

Vue3 Vue CLI multi-environment configuration

Table of contents 1. Introduction 2. Switching 1....

Basic operations of mysql learning notes table

Create Table create table table name create table...

js to achieve the effect of dragging the slider

This article shares the specific code of how to d...

100-1% of the content on the website is navigation

Website, (100-1)% of the content is navigation 1....

Binary installation of mysql 5.7.23 under CentOS7

The installation information on the Internet is u...