What is Docker.qcow2?
Asked Answered
P

3

31

I was looking at my disk with DaisyDisk and I have a 30GB something called Docker.qcow2. More specifically, DaisyDisk puts it under ~/Library/Containers/com.docker.docker/Data/vms/0/Docker.qcow2. Is it some kind of cache? Can I delete it? I have a lot of images from old projects that I won't ever use and I'm trying to clear up my disk.

Pestana answered 17/4, 2018 at 21:26 Comment(0)
P
33

The .qcow2 file is exposed to the VM as a block device with a maximum size of 64GiB by default. As new files are created in the filesystem by containers, new sectors are written to the block device. These new sectors are appended to the .qcow2 file causing it to grow in size, until it eventually becomes fully allocated. It stops growing when it hits this maximum size.

You can stop Docker and delete this file, however deleting it will also remove all your containers and images. And Docker will recreate this file on start.

Portemonnaie answered 11/5, 2018 at 14:48 Comment(0)
D
21

If you stumbled upon this, you're probably not stoked about a 64gb file. If you open up Docker > Preferences, you can tone it down quite a bit to a more reasonable size. Doing this will delete the old cow file, and that will delete your containers, so be careful.

enter image description here

Devy answered 18/6, 2019 at 1:33 Comment(2)
Note, this file is sparsely populated. E.g. the setting of 16.0GB above is only using 1.2GB at present. Depending on how you view the file, you'll see the max file size or the actual size on disk.Whitted
It was at a full 64gb when I found it. Changing the size also deleted the old content.Devy
C
4

I've had the same issue. Instead of deleting the file or adjusting the size using the settings simply use the following commands:

docker images

This will show all of the images on your system and the size of each image (you'd be surprised how quickly this can get out of hand).

docker image rm IMAGEID

This will remove the image with the ID that you can get from the images command above.

I use this method and it frees up a lot of disk space.

Cenotaph answered 26/1, 2021 at 15:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.