Docker runs operations with specified memory

Docker runs operations with specified memory

as follows:

-m, --memory Memory limit, the format is a number plus a unit, the unit can be b, k, m, g. Minimum 4M
--memory-swap Total limit of memory + swap partition size. Same format as above. Required -m sets the soft limit on memory. Same format as above --oom-kill-disable Whether to prevent OOM killer from killing containers, not set by default --oom-score-adj The priority of the container being killed by OOM killer, the range is [-1000, 1000], the default is 0
--memory-swappiness is used to set the virtual memory control behavior of the container. The value is an integer between 0 and 100. --kernel-memory Kernel memory limit. Same format as above, minimum size is 4M

See examples:

[root@sannian ~]# docker run -d -m 1G --memory-swap 3G -p 9999:80 --restart=always --name gitlab twang2218/gitlab-ce-zh
a3254078a79a084f3f3bed5f4ade3e26c7d86951cd822d95b113227d75b00097
[root@sannian ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a3254078a79a twang2218/gitlab-ce-zh "/assets/wrapper" 21 minutes ago Up 2 minutes (healthy) 22/tcp, 443/tcp, 0.0.0.0:9999->80/tcp gitlab
[root@sannian ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
twang2218/gitlab-ce-zh latest 18da462b5ff5 3 months ago 1.61GB
registry-vpc.cn-hangzhou.aliyuncs.com/wenty/jumpserver latest 055f42f305f5 7 months ago 1.41GB
registry.cn-hangzhou.aliyuncs.com/wenty/jumpserver latest 055f42f305f5 7 months ago 1.41GB
registry.jumpserver.org/public/jumpserver 1.0.0 055f42f305f5 7 months ago 1.41GB
registry.jumpserver.org/public/jumpserver latest 055f42f305f5 7 months ago 1.41GB

Supplement: Docker run -m specifies the memory size but it does not take effect

When executing docker run, I want to specify the memory size, so I use the -m parameter

The error is as follows

#docker run -id -m 3g -p 7001:7001 197.3.16.51/sysmgr/mywebapptest_app_weblogic:20180820047 WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap. 52380a4896f3f916cd0f95f97e233b30d9406840e10c0c53484b3be9000d0321

Then I found that although I set the heap size to 5G, the container was still created and the 3G limit did not take effect.

After checking the information, I found that this error was because the relevant functions of the host kernel were not enabled.

Solution

Just follow the settings below

Step 1:

Edit the /etc/default/grub file and change the GRUB_CMDLINE_LINUX line to

GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"

Step 2:

Update GRUB, that is, execute $ sudo update-grub

Step 3:

Reboot the system.

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:
  • Solution to ES memory overflow when starting docker
  • Docker View JVM Memory Usage
  • Docker memory monitoring and stress testing methods
  • Docker View Process, Memory, and Cup Consumption
  • Insufficient memory problem and solution when docker starts elasticsearch
  • How to limit the memory available to a container in Docker

<<:  Comparative Analysis of MySQL Binlog Log Processing Tools

>>:  Differences and usage examples of for, for...in, for...of and forEach in JS

Recommend

CSS to achieve the sticky effect of two balls intersecting sample code

This is an effect created purely using CSS. To pu...

Install mysql 5.6 from yum source in centos7.4 system

System environment: centos7.4 1. Check whether th...

Detailed explanation of MySQL EXPLAIN output columns

1. Introduction The EXPLAIN statement provides in...

HTML+CSS to implement the sample code of the navigation bar drop-down menu

Effect The pictures in the code can be changed by...

Two ways to install Python3 on Linux servers

First method Alibaba Cloud and Baidu Cloud server...

Docker+nacos+seata1.3.0 installation and usage configuration tutorial

I spent a day on it before this. Although Seata i...

In-depth understanding of umask in new linux file permission settings

Preface The origin is a question 1: If your umask...

Detailed steps for building a React application with a Rails API

Table of contents Backend: Rails API part Front-e...

Detailed explanation of the construction and use of Docker private warehouse

The image can be saved on hub.docker.com, but the...

How to install Nginx in CentOS

Official documentation: https://nginx.org/en/linu...

Solution to Element-ui upload file upload restriction

question Adding the type of uploaded file in acce...

Specific use of lazy loading and preloading in js

Delayed loading (lazy loading) and preloading are...