K
K
KBBS2021-01-25 09:28:53
Docker
KBBS, 2021-01-25 09:28:53

How can I set vm.overcommit_memory=1 and transparent_hugepage=never in Ubuntu which is running WSL?

Hello.
Help solve the problem.

Given:
Windows-10;
wsl2;
docker desktop.

Docker uses wsl.
Redis is spinning in the docker.
The latter requires vm.overcommit_memory to be set to 1 and transparent_hugepage disabled.

As I understand it, I have to change these values ​​on the host system. Those. in the one that runs under wsl, which is used by Docker.
In principle, this cannot be done at the container level.
For example, when trying to execute sysctl -w vm.overcommit_memory=1 writes something like: the file system is read-only.
At the level of the host system, everything is done.
sysctl -w vm.overcommit_memory=1 works.
echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled - works.
The values ​​change and the changed values ​​are displayed in the container. Which confirmed my conclusion that they need to be changed in the host system.

The problem is that I can only change them manually after starting the wsl distribution. Here is the way I mentioned above.
But I'd like to automate this somehow.
For example, if I put vm.overcommit_memory=1 in /etc/sysctl.conf, it doesn't work. The feeling is that the config is simply ignored.

Can I change these settings at the configuration level at all?
In principle, I would even be satisfied with a version of the script that would work out at the start of the host system. But I didn't find a way to do it.

I will be glad to any ideas.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nurlan, 2017-06-19
@daager

Set the file encoding to utf8 or force it on the page in the browser and read what the error is.
My crystal ball tells me that you may not have a license.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question