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

Linux yum package management method

Introduction yum (Yellow dog Updater, Modified) i...

Manual and scheduled backup steps for MySQL database

Table of contents Manual backup Timer backup Manu...

MySql inserts data successfully but reports [Err] 1055 error solution

1. Question: I have been doing insert operations ...

Faint: "Use web2.0 to create standard-compliant pages"

Today someone talked to me about a website develo...

How to deal with time zone issues in Docker

background When I was using Docker these two days...

Introducing multiple custom fonts in CSS3

Today I found a problem in HTML. There are many d...

JavaScript Sandbox Exploration

Table of contents 1. Scenario 2. Basic functions ...

Summary and practice of javascript prototype chain diagram

Table of contents Prototype chain We can implemen...

MySQL common backup commands and shell backup scripts sharing

To back up multiple databases, you can use the fo...

How to implement form validation in Vue

1. Installation and use First, install it in your...

Intellij IDEA quick implementation of Docker image deployment method steps

Table of contents 1. Docker enables remote access...

Summary of essential knowledge points for MySQL query optimization

Preface Query optimization is not something that ...