Docker Qcow2 Vs Raw

  1. Docker Qcow2 Vs Rawlings
  2. Docker Qcow2 Vs Raw Data
  3. Docker Qcow2 Vs Raw Dog Food
  4. Docker Mac Raw Vs Qcow2

For 'thin provisioning' go with qcow2. It can be converted in many formats, if needed. It is a question of compatibility and convenience vs sheer power and stability, but imo, in this case, the gains with raw are far from compensating the losses in the other chapters, but to each their own. The choice between base image + qcow2 overlay vs multiple full copies depends on your priority: For absolute performance, use fallocated RAW images. This has the downside of not supporting snapshot, with in most environments is a too high price to pay; For flexibility and space-efficiency use RAW base images + Qcow2 overlays. Use raw disk image and not qcow2. Consider using raw image or partition for a partition, especially with Microsoft SQL database files because qcow2 can be very slow under such type of load. Trace Flag T8038 with Microsoft SQL Server. Setting the trace flag -T8038 will drastically reduce the number of context switches when running SQL 2005 or 2008.

This guide is for existing VM’s.

Backup VM config

Replace vmname with Virtual Machine (Domain) name. You can find correct name by running virsh list --all

Image Conversion

Find path of existing image (in qcow2) format

Will show something like:

Conversion

Sample command is:

So in this case, it will be:

At this point conversion is complete.

Edit VM Configuration

Edit VM Config

Run following command to open editor.

Find lines like below:

Replaceqcow2 withraw Ain 2 places highlighted above.

Your update config will look like below:

Save your changes and exit editor.

Docker Qcow2 Vs Rawlings

Start VM

Docker Qcow2 Vs Raw Data

Run following command:

At this point you can run your disk I/O benchmarks again to check speed.

I wanted to write it as a comment toarticle of @Evgeny Shvarov . But it happens to be so long, so, decided to post it separately.

I would like to add a bit of clarification about how docker uses disk space and how to clean it. I use macOS, so, everything below, is mostly for macOS, but docker commands suit any platform.

While docker comes from Linux, it works there on the same filesystem by default. But on Windows and macOS, it works in a small virtual machine with its own Linux inside. And disk's space there is limited my settings in docker. In my case, I have configured it to use up to 112 GB.

So, when you actively working with Docker, your space inside will go out. You can check how docker spends all that space with the command.

In macOS with the latest versions of Docker, used the raw format of the disk (previously was qcow2). And together with APFS filesystem in macOS, this file may take up less physical space than file size itself. Look at these two commands.

ls command shows the size of my Docker.raw file as 104Gb, while du command shows real size on the disk and it is 88Gb

Well, docker system df showed me, that I can reclaim some space. Let's do this.

This command deletes any stopped containers and any non-tagged images which not in use by any tagged images. And can be deleted safely.

You maybe noticed that it was reclaimed just only 5.5 GB, while docker system df said about 55GB. That's because, df counts all not active images, not just dangled ones. If you want to delete all those images as well, you can use this command. Which deletes any images which not used in running containers at the moment. So, if you don't have any running containers, it will delete all local images.

I just reclaimed only dangled images and stopped containers. How much space my docker use now.

Mac

Docker Qcow2 Vs Raw Dog Food

As you can see, it uses already less size. ls will show the same result. The size of the file mostly grows.

Docker Qcow2 Vs Raw

But for macOS is mostly important how much space is used on a physical disk.

And as you can see it now 69GB, and it is about 19GB less than it was before.

So, for macOS users, it does not really matter how much size of the file, with APFS optimizations it can be less in reality.

Docker Mac Raw Vs Qcow2

Another way to prune old images with some filter by creation date. Like this example, will delete all images which were created more than 10 days ago, but will keep images which currently in use by containers.