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

Execute the shell or program inside the Docker container on the host

In order to avoid repeatedly entering the Docker ...

VMware and CentOS system installation method to reset the root password

Today's Tasks 1. Choice of Linux distribution...

Detailed explanation of MySQL trigger trigger example

Table of contents What is a trigger Create a trig...

MySQL time types and modes details

Table of contents 1. MySQL time type 2. Check the...

Detailed explanation of common methods of JavaScript Array

Table of contents Methods that do not change the ...

Detailed tutorial on installing Protobuf 3 on Ubuntu

When to install If you use the protoc command and...

Docker Compose network settings explained

Basic Concepts By default, Compose creates a netw...

Innodb system table space maintenance method

Environmental Description: There is a running MyS...

How to perfectly implement the grid layout with intervals on the page

Typical layout examples As shown in the above pic...

How to install mongodb 4.2 using yum on centos8

1. Make a repo file Refer to the official install...

The big role of HTML meta

There are two meta attributes: name and http-equiv...

SQL statements in Mysql do not use indexes

MySQL query not using index aggregation As we all...

Vue uses Baidu Maps to realize city positioning

This article shares the specific code of Vue usin...