121

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.

8 Answers 8

200

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.

4
  • 1
    This worked even when the GUI (version 5.0.16) would not.
    – MikeF
    Jan 26, 2017 at 20:58
  • 7
    This answer should be at the top
    – nakajuice
    Jun 6, 2017 at 13:35
  • 8
    Note that after the command is executed docker-machine inspect won't show any changes. However, if you run docker stats you'll see that the changes have been applied.
    – slovit
    Oct 29, 2018 at 18:58
  • @slovit and others: You can then modify the docker-machine config.json file to reflect the actual size. Example: for default, as used in the example solution, modify the ~/.docker/machine/machines/default/config.json file so that the Memory (and CPU if also modified) subproperty under Driver is changed to 4096. Then, docker-machine inspect will show the proper value. May 3, 2020 at 1:35
113

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.

3
  • This definitely seems like the right place to adjust memory allocation. However, still getting the same error after restarting this VM. In the check-system program (github.com/memsql/memsql-docker-quickstart/blob/master/…), I am seeing these lines which would determine this error. ONE_MB = 1024 ** 2, virtual_memory = psutil.virtual_memory(), if virtual_memory.total < ONE_MB * 3700: sys.stderr.write("Error: MemSQL requires at least 4 GB of memory to run.\n") .
    – DJElbow
    Sep 29, 2015 at 18:23
  • 2
    Wasn't able to get this working by altering the config, but deleting and recreating the docker machine vm as shown above solved the issue!
    – DJElbow
    Sep 29, 2015 at 20:12
  • Sure, I clean the second way, seems it doesn't work any more.
    – BMW
    Jan 11, 2016 at 23:06
94

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)

5
  • 3
    This has moved to Advanced tab. Thanks for sharing this.
    – GabLeRoux
    Mar 24, 2017 at 16:06
  • Man that was both obvious and completely unintuitive - thank you! Oct 31, 2017 at 23:07
  • Does those changes also apply if I use dinghy with virtualbox ? Or I should only use VBoxManage to adjust mem size ?
    – Artur79
    Feb 6, 2018 at 8:48
  • 3
    Is there a command line equivalent to this? I have Docker for mac but apparently docker-machine ls gives me nothing so I can't modify the default machine. May 17, 2018 at 16:13
  • 1
    It's Preferences -> Resources as of today.
    – swedge218
    Aug 12, 2020 at 12:26
45

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.

3
  • 3
    This works but note that docker-machine inspect will continue to report the original amount of memory even after altering it in the VirtualBox GUI.
    – Tamlyn
    Feb 2, 2016 at 19:16
  • 2
    That's true, in order to have docker-machine inspect report the accurate amount, you do have to edit config.json (that's where inspect gets its information). Mar 15, 2016 at 20:54
  • 1
    Doing it in Virtualbox is the simplest Aug 26, 2016 at 15:33
14

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

14

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
1
4

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

1
  • I found it under ~/.docker/machine/machines/default/config.json. Thanks 👍 Jul 2, 2019 at 15:58
2

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.