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
Table of contents Find and fix table conflicts Up...
Table of contents 1. Demo Project 1.1 Interface P...
Solution to mysql not closing: Right-click on the...
Let’s install Nginx and try it out. Please note t...
Before you begin Have a cloud server, mine is Ten...
When using a cloud server, we sometimes connect t...
Linux grep command The Linux grep command is used...
Preface This article mainly introduces the releva...
Step 1: Install the deep "graphics driver&qu...
This article is a self-written imitation of the X...
Table of contents 1. Create components using func...
Docker is an open source container engine that he...
Recently, I encountered many problems when instal...
Today I received a disk alarm exception. The 50G ...
JDK download address: http://www.oracle.com/techn...