How do you use sudo sysctl in Docker Desktop terminal?

I tried using a sudo command in terminal, but it gave me this.

sudo : The term ‘sudo’ is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1

  • sudo sysctl -w vm.max_map_count=262144
  •   + CategoryInfo          : ObjectNotFound: (sudo:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

Can someone please find a fix to this? I’m completely new to this and I’m only using docker to install someone else’s project. I appreciate your help.

There is nothing to fix. The Terminal feature in Docker Desktop just opens a terminal on your host. On Windows, it is a PowerShell. You may hear about sudo for Windows, but sysctl is still a Linux command. If you need to change the parameter in Docker Desktop’s virtual machine when using the WSL2 backend, you can open a WSL2 distribution and run the command there. Or you can run it through a container like this:

docker run --rm -it --privileged bash sysctl -w vm.max_map_count=262144

But this is the default value anyway in Docker Desktop on my MacBook.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.