Last Updated: September 27, 2021
·
2.237K
· itseranga

Increase boot2docker space allocation in OSX

Docker with boot2docker

Space issue with boot2docker

  • Sometime when working with docker in OSX environment you could get the error

    no space left on device

  • The reason for this error is

    total size of docker images is exceed than the space allocates to boot2docker VM

  • To overcome this issue, you could simply remove the unwanted images.

  • Sometimes this won't works, because you could be get some situation where docker daemon cannot starts(because of the space issue on boot2ocker VM)

  • In this situation you have to increase the space allocates to boot2docker VM

Increase boot2docker VM space

  • You can increase the boot2docker VM space without removing/destroying your existing images.
  • More info: boot2docker volume resize
  • In here I'm going to demonstrate you how to initialise boot2docker with more space and memory via boot2docker profile.
  • In this way you have remove/destroy existing boot2docker VM(So it will remove all your local docker images/containers/layers)
  • Following are the steps

1. Stop and destroy boot2docker

boot2docker stop
boot2docker destroy

2. Create boot2docker profile

  • Create boot2docker config file in your home ~/.boot2docker/profile (create this directory and file if not exists)
  • We can configure boot2docker VM space and memory via this configuration file
  • More info: boot2docker configuration
  • Add following content to ~/.boot2docker/profile file
# VM disk image size in MB
DiskSize = 61440

# VM memory size in MB
Memory = 6144
  • Things to notice here

    1. DiskSize = 61440 will allocates 60 GB space to boot2docker VM
    2. Memory = 6144 will allocates 6 GB memory to boot2docker VM
  • After define configurations you have to reinitialise boot2docker VM

3. Reinitialise boot2docker

boot2docker init
boot2docker start
  • This commands will creates fresh boot2docker VM with 60GB space and 6GB memory
  • You can verify this configuration via ssh'ing to boot2docker VM
# connect to boot2docker VM
boot2docker ssh

# verify configuration
df -h
cat /proc/meminfo
  • Following is an example output of cat /proc/meminfo

Picture

References