How to increase docker-machine memory Mac

MacosDockerVirtualboxDocker MachineSinglestore

Macos Problem Overview


I am new to Docker, and trying to go through this tutorial setting up MemSQL from a Docker image - http://docs.memsql.com/4.0/setup/docker/ . I am on a Mac, and the tutorial uses boot2docker which seems to have been deprecated.

The VM needs 4GB memory to run. The tutorial specifies how to do this with boot2docker but I cannot find a way to do this with the docker-machine/docker toolbox.

Here is the command I am using and the error I am getting just trying to go through the tutorial without altering the boot2docker config.

docker run --rm --net=host memsql/quickstart check-system
Error: MemSQL requires at least 4 GB of memory to run.

Macos Solutions


Solution 1 - Macos

You can do this via the command line. For example, to change the machine from the default 1cpu/2048MB RAM run:

docker-machine stop
VBoxManage modifyvm default --cpus 2
VBoxManage modifyvm default --memory 4096
docker-machine start

You can then check your settings:

VBoxManage showvminfo default | grep Memory
VBoxManage showvminfo default | grep CPU

And for docker-machine inspect to report the correct state of things, edit ~/.docker/machine/machines/default/config.json to reflect your changes.

Solution 2 - Macos

when you create docker machine, you can nominate the memory size:

docker-machine create -d virtualbox --virtualbox-memory 4096 default

Let me know if this helps.

Solution 3 - Macos

For Docker version 1.12.1 (build: 12133) and higher on macOS there is an option to change CPU's and RAM from UI and restart docker. You can find the preferences from toolbar. Attaching images for clarity.

Update Aug 2020: Preferences -> Resources (thank you to @swedge218)

Old Step (probably defunct now): Preferences -> Advanced -> adjust resources -> Apply & Restart

https://www.dropbox.com/s/znltd1v4r00nfpu/Screenshot%202017-03-24%2012.12.58.png?dl=0

docker advanced tab (memory)

Solution 4 - Macos

Docker Machine maintainer here. I don't think adjusting the config.json manually will work.

Your two options are to either create the machine with --virtualbox-memory set, or to adjust the VM's memory in the VirtualBox GUI ("Settings > System" for that VM I think). Make sure the machine is powered off and there should be a little slider that works.

EDIT: Another answer shows that you can do the in-place operation from the command line as well using VBoxManage.

Solution 5 - Macos

I couldn't get the other answers to work. The only thing that worked for me was to remove the default machine and re-create it with more memory.

docker-machine rm default
docker-machine create -d virtualbox --virtualbox-memory=4096 --virtualbox-cpu-count=2 --virtualbox-disk-size=50000 default

This fix was found here: https://www.ibm.com/developerworks/community/blogs/jfp/entry/Using_Docker_Machine_On_Windows?lang=en

Solution 6 - Macos

Other answers showed how to change the memory using VBoxManage:

docker-machine stop default
VBoxManage modifyvm default --memory 4096
docker-machine start default

To confirm the change from the command line:

VBoxManage showvminfo default | grep Memory

OR

docker-machine ssh default free

Solution 7 - Macos

fox xhyve (another virtualization under macos) you can modify ~/.docker/machine/default/config.json property Driver/Memory (default to 1024) then restart docker machine to apply changes

Solution 8 - Macos

APPLE SILICON

I was looking for a solution for Apple Silicon, and from what I understand docker-machine was deprecated (link), so I ended up using colima (link).

As per colima documentation one can define number of cpus and available ram like:

colima start --cpu 1 --memory 2 --disk 10

and to modify an existing VM:

colima stop
colima start --cpu 4 --memory 8

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDJElbowView Question on Stackoverflow
Solution 1 - MacosRan RubinsteinView Answer on Stackoverflow
Solution 2 - MacosBMWView Answer on Stackoverflow
Solution 3 - MacosSrikar AppalarajuView Answer on Stackoverflow
Solution 4 - MacosnathanleclaireView Answer on Stackoverflow
Solution 5 - MacosbbuieView Answer on Stackoverflow
Solution 6 - MacoscpepView Answer on Stackoverflow
Solution 7 - MacosdchekmarevView Answer on Stackoverflow
Solution 8 - MacosMatejView Answer on Stackoverflow