Change boot2docker memory assignment
Asked Answered
S

6

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?

Shan answered 26/6, 2014 at 3:56 Comment(0)
S
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.

Solingen answered 26/6, 2014 at 14:41 Comment(8)
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: a551732Democracy
I get the same issue as @DemocracyDonnenfeld
Can you try running boot2docker version and boot2docker help? The flag exists (at least) since 1.1.2 for Mac OSXJokester
Mine also complains that -m is an invalid flag. Client version 1.2.0, Git hash: a551732Kaolin
Ah, this is a bug that apparently have been fixed in the master branch (github.com/boot2docker/boot2docker-cli/pull/243). A work around is to manually change the Memory using the VirtualBox Admin GUI program.Kaolin
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.Palla
WARNING: This will delete your downloaded images :(Hurwit
No need to delete, look at the below answers, modify works. Voting them up, please do the same, so ppl don't waste time.Methadone
S
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.

Soonsooner answered 17/10, 2014 at 15:18 Comment(2)
In recent versions of boot2docker, the vm name is boot2docker-vmNorine
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.Soonsooner
A
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
Arsenopyrite answered 4/2, 2015 at 12:20 Comment(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 6144Methadone
S
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.

Solingen answered 26/6, 2014 at 14:41 Comment(8)
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: a551732Democracy
I get the same issue as @DemocracyDonnenfeld
Can you try running boot2docker version and boot2docker help? The flag exists (at least) since 1.1.2 for Mac OSXJokester
Mine also complains that -m is an invalid flag. Client version 1.2.0, Git hash: a551732Kaolin
Ah, this is a bug that apparently have been fixed in the master branch (github.com/boot2docker/boot2docker-cli/pull/243). A work around is to manually change the Memory using the VirtualBox Admin GUI program.Kaolin
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.Palla
WARNING: This will delete your downloaded images :(Hurwit
No need to delete, look at the below answers, modify works. Voting them up, please do the same, so ppl don't waste time.Methadone
C
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.

Cornet answered 5/8, 2015 at 7:54 Comment(1)
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).Cornet
S
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.

Sedlik answered 5/8, 2015 at 8:2 Comment(0)
D
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"

Dade answered 13/12, 2017 at 12:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.