2

I am trying to run ELK docker images on my windows10 as below.

  C:\WINDOWS\system32> docker run  -p 5601:5601 -p 9200:9200 -p 9300:9300 -p 5044:5044  -p 9600:9600 -p 9700:9700 -it --memory="3g" --name elk sebp/elk

I got below error, could i set vm.max_map_count at docker run command line?

[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

Any suggestion or hints are more than welcome!

stewchicken
  • 463
  • 1
  • 8
  • 20
  • Does this answer your question? [Using Docker-Desktop for Windows, how can sysctl parameters be configured to permeate a reboot?](https://stackoverflow.com/questions/69214301/using-docker-desktop-for-windows-how-can-sysctl-parameters-be-configured-to-per) – KennetsuR Nov 30 '21 at 02:48

3 Answers3

9

This can be done via WSL's support of a .wslconfig file (stored in your Windows %userprofile% folder), which can apply and persist such setting across restarts, for example:

[wsl2]
kernelCommandLine = sysctl.vm.max_map_count=262144

(Note that's NOT a space after sysctl, but a period, which is necessary for it to work, from my testing.)

After saving the file, restart wsl with wsl --shutdown. Before reopening your WSL, make sure the vm is shutdown, using wsl -l -v, as it can take several seconds sometimes.

For more on this file, its many available settings, and even that need to wait for the shutdown, see the docs.

charlie arehart
  • 6,590
  • 3
  • 27
  • 25
4

I've had similar experience with running elastic/elastic, so this might help.

When you're running it in WSL2, you might want to log in to your WSL VM: wsl -d docker-desktop (Where docker-desktop is the name of the vm, you can check for them with wsl --list

Once in your docker-desktop, do the following:

echo "vm.max_map_count = 262144"> /etc/sysctl.d/999-docker-desktop-conf

followed by: sysctl -w vm.max_map_count=262144

You can then exit the docker-host by typing exit.

Mercatres
  • 76
  • 4
0

Persistent setting via windows powershell:

wsl su-
 [sudo] password for root:<type your root password>

sysctl vm.max_map_count
vi /etc/sysctl.conf
  vm.max_map_count = 262144
sysctl -p
sysctl vm.max_map_count
seaman29
  • 79
  • 1
  • 8