您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

max_map_count.md 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ---
  2. sidebar_position: 7
  3. slug: /max_map_count
  4. ---
  5. # Update vm.max_map_count
  6. ## Linux
  7. To check the value of `vm.max_map_count`:
  8. ```bash
  9. $ sysctl vm.max_map_count
  10. ```
  11. Reset `vm.max_map_count` to a value at least 262144 if it is not.
  12. ```bash
  13. # In this case, we set it to 262144:
  14. $ sudo sysctl -w vm.max_map_count=262144
  15. ```
  16. This change will be reset after a system reboot. To ensure your change remains permanent, add or update the `vm.max_map_count` value in **/etc/sysctl.conf** accordingly:
  17. ```bash
  18. vm.max_map_count=262144
  19. ```
  20. ## Mac
  21. ```bash
  22. $ screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
  23. $ sysctl -w vm.max_map_count=262144
  24. ```
  25. To exit the screen session, type Ctrl a d.
  26. ## Windows and macOS with Docker Desktop
  27. The vm.max_map_count setting must be set via docker-machine:
  28. ```bash
  29. $ docker-machine ssh
  30. $ sudo sysctl -w vm.max_map_count=262144
  31. ```
  32. ## Windows with Docker Desktop WSL 2 backend
  33. To manually set it every time you reboot, you must run the following commands in a command prompt or PowerShell window every time you restart Docker:
  34. ```bash
  35. $ wsl -d docker-desktop -u root
  36. $ sysctl -w vm.max_map_count=262144
  37. ```
  38. If you are on these versions of WSL and you do not want to have to run those commands every time you restart Docker, you can globally change every WSL distribution with this setting by modifying your %USERPROFILE%\.wslconfig as follows:
  39. ```bash
  40. [wsl2]
  41. kernelCommandLine = "sysctl.vm.max_map_count=262144"
  42. ```
  43. This will cause all WSL2 VMs to have that setting assigned when they start.
  44. If you are on Windows 11, or Windows 10 version 22H2 and have installed the Microsoft Store version of WSL, you can modify the /etc/sysctl.conf within the "docker-desktop" WSL distribution, perhaps with commands like this:
  45. ```bash
  46. $ wsl -d docker-desktop -u root
  47. $ vi /etc/sysctl.conf
  48. ```
  49. and appending a line which reads:
  50. ```bash
  51. vm.max_map_count = 262144
  52. ```