Docker underlying technology: The two core technologies at the bottom of Docker are Namespaces and Control groups. Namespace: It is the core technology of container virtualization and is used to isolate containers and resolve conflicts between containers. This is mainly achieved through the following six isolation technologies:
As long as these six items are decoupled, even if other system resources are shared, the computer will consider them to be in two different systems. cgroup (controls the resource usage of programs) The main purpose of implementing cgroup is to provide a unified interface for resource management at different user levels. From resource control of a single process to virtualization at the operating system level. The role of cgroup: 1) Resource limitation: cgroup can limit the total amount of resources used by the process group. Application of cgroup: 1) Limitations of memory and swap partition: The container consists of two parts: physical memory and swap In Docker, you can control the usage of container memory through parameters: -m or --memory: Set memory usage limit --memory-swap: Set the usage limit of swap (swap partition) //Based on the centos image, the memory limit is 200M and the memory of the swap partition is 300M [root@sqm-docker01 ~]# docker run -it -m 200M --memory-swap 300M centos Enter the container to view the limited memory: [root@05a0be7b870a /]# cat /sys/fs/cgroup/memory/memory.limit_in_bytes 209715200 #Displays bytes [root@05a0be7b870a /]# cat /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes 314572800 2) Container CPU restrictions: Use -c or --cpu-shares to set the cpu weight of the container experiment. If not set, the default is 1024. //Based on the centos image, run a container named containerB with a cpu weight limit of 512: [root@sqm-docker01 ~]# docker run -it --name containerB -c 512 centos [root@b2cf9f28ce1d /]# cat /sys/fs/cgroup/cpu/cpu.shares 512 3) Limit the container's Block io (disk read and write):
//Create a container named testA and limit the amount of disk writes per second to 30MB. [root@sqm-docker01 ~]# docker run -it --name testA --device-write-bps /dev/sda:30MB centos Write data for testing:
It can be found that the amount written per second is 80M, which takes about 26s. When writing to disk normally: The above is all the knowledge points about Docker underlying technology introduced this time. Thank you for your learning and support for 123WORDPRESS.COM. You may also be interested in:
|
<<: Can't connect to local MySQL through socket '/tmp/mysql.sock' solution
>>: mysql code to implement sequence function
This article installs Google Input Method. In fac...
1. Select Edit → Virtual Network Editor in the me...
In daily development tasks, we often use MYSQL...
The complete steps of Centos7 bridge network conf...
1. The catalina.bat must be set to UTF-8. If I do...
1. Download the alpine image [root@docker43 ~]# d...
Table of contents 1. Use the warehouse to create ...
Preface After a long time of reading various mate...
I recently used the ssm framework when doing a pr...
HTML-centric front-end development is almost what ...
This article summarizes various ways to implement...
1. Tcl script file circle.tcl code comments #Set ...
Table of contents 01 Create invisible columns 02 ...
Preface There are 4 types of operators in MySQL, ...
The first method: docker installation 1. Pull the...