0

I.e., one can change it in Docker's settings picture (i.e., using GUI). Can I limit the memory using the command line instead using OSX?

The problem is that after I set its memory limit to 10GB I cannot start Docker anymore and it just hangs.

Update: I did read this question, but I believe it doesn't apply to me since I don't have a virtual box.

A. Karnaval
  • 727
  • 2
  • 8
  • 12
  • possible duplicate of https://stackoverflow.com/questions/32834082/how-to-increase-docker-machine-memory-mac – Ammar Jun 25 '19 at 17:10
  • see https://docs.docker.com/config/containers/resource_constraints/ – LinPy Jun 25 '19 at 17:41
  • @Ammar I use OSX so the accepted answer doesn't really work for me unfortunately (`docker-machine create -d virtualbox --virtualbox-memory 4096 default`) – A. Karnaval Jun 25 '19 at 21:12
  • @LinSel I did read it, but I could find a way to set a memory limit for a docker engine (not for a container). – A. Karnaval Jun 25 '19 at 21:12

1 Answers1

0

Docker for mac use hyperkit vm just like hyperv on windows10, the settings could be in some place like next:

/Users/<username>/Library/Group Containers/group.com.docker/settings.json

The default value is:

{
  "dockerAppLaunchPath" : "/Applications/Docker.app",
  "proxyHttpMode" : "system",
  "buildNumber" : "31259",
  "cpus" : 2,
  "diskSizeMiB" : 61035,
  "version" : "2.0.0.3",
  "settingsVersion" : 1,
  "channelID" : "stable",
  "memoryMiB" : 2048,
  "displayedWelcomeMessage" : true,
  "displayedWelcomeWhale" : true,
  "linuxDaemonConfigCreationDate" : "2019-06-26 02:32:30 +0000",
  "diskPath" : "Library/Containers/com.docker.docker/Data/vms/0/Docker.qcow2"
}

So, you can use command to modify the value you want to change, next is an example to change memory to 3072M, or just use any editor to directly modify the value:

sed -i 's/"memoryMiB".*/"memoryMiB" : 3072,/g' /Users/`id -un`/Library/Group\ Containers/group.com.docker/settings.json

Finally, in command restart the docker as next:

osascript -e 'quit app "Docker"' && open -a Docker
atline
  • 28,355
  • 16
  • 77
  • 113