34

I've been playing around with docker on a mac so I need to install boot2docker to make it work.

I have a pretty powerful machine and a very resource hungry app so I want to up the available memory from the default which is 1GB to something like 8GB.


This is what I've tried

Booting boot2dock with the --memory param

boot2docker --memory=8116 boot

Change the config file

Verbose = true
VBM = "VBoxManage"
SSH = "ssh"
SSHGen = "ssh-keygen"
SSHKey = "/Users/mjsilva/.ssh/id_boot2docker"
VM = "boot2docker-vm"
Dir = "/Users/mjsilva/.boot2docker"
ISO = "/Users/mjsilva/.boot2docker/boot2docker.iso"
VMDK = ""
DiskSize = 20000
Memory = 8116
SSHPort = 2022
DockerPort = 2375
HostIP = "192.168.59.3"
DHCPIP = "192.168.59.99"
NetMask = [255, 255, 255, 0]
LowerIP = "192.168.59.103"
UpperIP = "192.168.59.254"
DHCPEnabled = true
Serial = false
SerialFile = "/Users/mjsilva/.boot2docker/boot2docker-vm.sock"

and then booting boot2docker

boot2docker boot

None of this approaches seem to work. I only end up only having the default memory.


The only way I manage to change was going to virtualbox GUI shutdown boot2docker, change it manually and boot it again.

Am I missing something?

mjsilva
  • 1,327
  • 3
  • 13
  • 21

6 Answers6

42

As boot2docker init -m did not work in my version of boot2docker, I just used VBoxManage command:

VBoxManage modifyvm boot2docker-vm --memory 3500

Also, using this I believe you can avoid destroying your VM, you should just stop it and then start again.

Aleksei Petrenko
  • 6,698
  • 10
  • 53
  • 87
  • 1
    In recent versions of boot2docker, the vm name is `boot2docker-vm` – rcoup Oct 28 '14 at 08:01
  • 5
    I realized after some time that boot2docker comes with fully capable VirtualBox UI. So you can just `boot2docker stop`, then type `VirtualBox` in your terminal, VirtualBox GUI will open where you can adjust parameters of you VM. – Aleksei Petrenko Mar 10 '15 at 13:44
30

It is NOT necessary to delete your boot2docker vm as Abel Muiño said.

Its enough what to do what Alex Petrenko proposed.

  1. boot2docker stop
  2. VBoxManage modifyvm boot2docker-vm --memory 3500
  3. boot2docker start
quexer69
  • 300
  • 3
  • 4
  • 1
    This comment is same as Alex Petrenko's Oct 2014 answer. For now voted them both up. But folks may want to consolidate them into one. For boot2doccer on windows I have used: `/c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe modifyvm boot2docker-vm --memory 6144` – arntg Aug 05 '15 at 19:32
23

You will need to re-initialize the boot2docker VM with the new memory settings:

$ boot2docker delete
$ boot2docker init -m 5555
... lots of output ...
$ boot2docker info
{ ... "Memory":5555 ...}

You can now boot2docker up and the image will always use the configured amount of memory.

Abel Muiño
  • 7,611
  • 3
  • 24
  • 15
  • 2
    When I try to run with the -m flag I get an `unknown shorthand flag: 'm' in -m` error. Does anyone know why? (boot2docker version returns `Client version: v1.2.0 Git commit: a551732` – cjhin Aug 27 '14 at 17:26
  • I get the same issue as @cjhin – Mark Sep 02 '14 at 19:24
  • Can you try running `boot2docker version` and `boot2docker help`? The flag exists (at least) since 1.1.2 for Mac OSX – Abel Muiño Sep 02 '14 at 20:50
  • Mine also complains that -m is an invalid flag. Client version 1.2.0, Git hash: a551732 – heyman Sep 08 '14 at 11:45
  • Ah, this is a bug that apparently have been fixed in the master branch (https://github.com/boot2docker/boot2docker-cli/pull/243). A work around is to manually change the Memory using the VirtualBox Admin GUI program. – heyman Sep 08 '14 at 12:02
  • 4
    See the answers below which mean you don't have to destroy your VM. I have up voted them and down voted this (sorry) so readers will go to the better answer. – idontgetoutmuch Feb 10 '15 at 11:11
  • WARNING: This will delete your downloaded images :( – Callum Rogers Jul 13 '15 at 22:29
  • 2
    No need to delete, look at the below answers, modify works. Voting them up, please do the same, so ppl don't waste time. – arntg Aug 05 '15 at 19:30
3

You can just tweak the settings in the GUI as well.

  1. Open VirtualBox
  2. Select 'boot2docker-vm'
  3. Click settings
  4. Select system
  5. Tweak your RAM

No need to delete your boot2docker vm.

Oliver Shaw
  • 5,235
  • 4
  • 26
  • 35
  • Not sure why I got down-voted. It's a legitimate change that is an alternative to command line tinkering that may suite non dev/opts users (content editors, analysts etc). – Oliver Shaw Oct 26 '15 at 16:32
3

When you are working on a Mac you do not necessarily need to use boot2docker. Usually I use docker-machine. With that you can also easily create a VM matching your requirements like:

docker-machine create --virtualbox-disk-size "50000" --virtualbox-cpu-count "4" --virtualbox-memory "8116" -d virtualbox dev

That creates a VM called dev with a 50GB disk, using 4 CPUs and 8GB of memory.

You can list your created VM with docker-machine ls and get the IP address to connect with docker-machine ip dev.

Henrik Sachse
  • 51,228
  • 7
  • 46
  • 59
1

In case your using boot2docker in hyperv. Docker has driver specific cli arguments.

LIST : https://docs.docker.com/machine/drivers/

HyperV : https://docs.docker.com/machine/drivers/hyper-v/#options

eg to create: docker-machine create --driver hyperv --hyperv-virtual-switch "Multiplexor" Boot2Docker --hyperv-memory "8192" --hyperv-cpu-count "4" --hyperv-disk-size "40000" --hyperv-static-macaddress "00:15:1D:01:F4:11"

z2z
  • 519
  • 1
  • 8
  • 16