Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to resize Docker for Mac Disk image and set the default size for new images

Set the default size for new Docker for Mac disk images

UPDATE: The instructions here are no longer necessary! Resizing the disk image is now possible right from the UI since Docker for Mac Version 17.12.0-ce-mac49 (21995).

If you are getting the error: No space left on device

Configuring the qcow2 size cap is possible in the current versions:

# my disk is currently 64GiB
$ /Applications/ info ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
image: /Users/djs/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
file format: qcow2
virtual size: 64G (68719476736 bytes)
disk size: 28G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false

# I can increase or decrease the default cap by:
$ cd ~/Library/Containers/com.docker.docker/Data/database/
$ git reset --hard
HEAD is now at 8635944 last-start-time changed at 1480009710
# The com.docker.driver.amd64-linux/disk/size file (and the disk dir) may not exist. If they don't exist create them.
$ cat com.docker.driver.amd64-linux/disk/size
$ echo 131072 > com.docker.driver.amd64-linux/disk/size
$ git add com.docker.driver.amd64-linux/disk/size
$ git commit -s -m 'increase size to 128GiB'
[master 60861de] increase size to 128GiB
 1 file changed, 1 insertion(+), 1 deletion(-)

# delete the disk -- this unfortunately deletes all images and containers
$ rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
# now I need to restart the app

For anyone wanting to use an external drive, you can also change the location of the Docker.qcow2 by editing the database key com.docker.driver.amd64-linux/disk/path. There is no UI element for this yet.

Credit for this procedure goes to @djs55 and was taken from .

Resize existing Docker for Mac disk image

If you are getting the error: No space left on device

Download gparted from

Close the Docker for Mac Application and wait for it to shutdown completely.

brew update
brew install qemu
cd ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/
qemu-img info Docker.qcow2   # shows you current disk size
qemu-img resize Docker.qcow2 +100G  # make it 100GB larger
qemu-img info Docker.qcow2    # check the new size
qemu-system-x86_64 -drive file=Docker.qcow2  -m 512 -cdrom ~/Downloads/gparted-live-0.27.0-1-i686.iso -boot d -device usb-mouse -usb

Wait for the VM to boot (can take a long time). For any questions asked (boot option, keyboard layout, language) the default is ok. Double click the gparted Icon. You should see swap space, the main partition and 100GB of free space. Select the main partition. Click Resize in the toolbar and drag the partition limit to fill the whole space. Click Apply. Wait for it to finish resizing and then quit the app and shutdown the gparted machine. Now start Docker for Mac again.

Run the following command to check the available diskspace inside the docker vm:

docker run --rm --privileged debian:jessie df -h

Make sure you shut down the gparted vm cleanly and don't access Docker.qcow2 while the procedure is running. Otherwise the disk image might get corrupted.

Credit for this procedure goes to the conversation in Especially to jgielstra.


This comment has been minimized.

Copy link

@diegodorgam diegodorgam commented Apr 26, 2017

and what should I do to shrink the image?


This comment has been minimized.

Copy link

@KjellKod KjellKod commented May 12, 2017

same thing. Just resize to shrink it. drag and drop


This comment has been minimized.

Copy link

@scsmith scsmith commented Sep 27, 2017

In case it helps anyone else, this didn't appear to work for me in edge (17.09.0-ce-rc3-mac30) however, going back to stable (17.06.2-ce-mac27) this worked like a charm. Thanks!


This comment has been minimized.

Copy link

@wamonite wamonite commented Nov 21, 2017

Doesn't work in 17.09.0-ce-mac35. If you roll back to 17.06.2-ce-mac27, that works fine. Upgrading to 17.09 leaves you with a qcow2 file with the correct virtual size, but containers are only given access to 64GB. Creating a new qcow2 on 17.09, Docker uses com.docker.driver.amd64-linux/disk/path but ignores size.
Edit: On a fresh install of 17.09, stopping Docker and running qemu-img resize Docker.qcow2 +100G then restarting works. VM looks like it resizes the fs itself. Moving the file seems to be broken via the UI though docker/for-mac#2170


This comment has been minimized.

Copy link

@animatedcreativity animatedcreativity commented Dec 4, 2017

I can confirm that it worked for me for 17.09.0-ce-mac35. I did +100GB and followed every step with gparted resizing.


This comment has been minimized.

Copy link
Owner Author

@stefanfoulis stefanfoulis commented Jan 28, 2018

Resizing the disk image is now possible right from the UI since Docker for Mac Version 17.12.0-ce-mac49 (21995).


This comment has been minimized.

Copy link

@poohsen poohsen commented Jul 4, 2018

i resized the image via the UI and then some more with qemu. Then used gparted to extend the image to the available space. Then docker qcow-tool told me that it [ERROR] Found a reference to cluster 914713 outside the file (max cluster 914703) from cluster 105.1448, which I successfully repaired with qemu-img check -r all.

After that, the Docker UI reported an error while starting up and gave me the option to cancel or "reset docker", which deleted the disk image. So: use these instructions at your own risk.


This comment has been minimized.

Copy link

@hakanai hakanai commented Sep 12, 2018

qemu-img is gone, so I ended up using:

$ /Applications/ info ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

This gives output like:

((version Three) (backing_file_offset 0) (backing_file_size 0)
 (cluster_bits 16) (size 207999729664) (crypt_method None) (l1_size 388)
 (l1_table_offset ((bytes 131072) (is_mutable false) (is_compressed false)))
  ((bytes 65536) (is_mutable false) (is_compressed false)))
 (refcount_table_clusters 1) (nb_snapshots 0) (snapshots_offset 0)
  (((dirty true) (corrupt false) (lazy_refcounts true) (autoclear_features 0)
    (refcount_order 4))))
    (((ty Incompatible) (bit 0) (feature Dirty))
     ((ty Incompatible) (bit 1) (feature Corrupt))
     ((ty Compatible) (bit 0) (feature Lazy_refcounts)))))))

Was trying to verify that the UI for setting the size actually worked, since it hasn't seemed to have helped anyway - I still hit a 60G limit when creating my images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment