Moving Docker Images Between Storage Drivers

How I retained my Docker images as I switched storage drivers from btrfs to overlay2

Why I had to move the images

I installed Kubernetes, and Kubernetes requires overlay2. After I switched from btrfs to overlay2, I could not access my images from the btrfs storage driver. I didn’t want to download ~2 GB of images again, so I had to move them.

How to move the images

Before you start, you can view the steps I followed (the entire output from my terminal) if you want to cross-check with mine.

I had already followed the instructions for using the overlay2 storage driver. You can follow that to make the switch. But before you do, export your docker images to a file. It’s simple: you run the following command.

docker image save –output=docker-image-export.tar <images…>

That will export all the images you specified to a docker-image-export.tar in your current directory.

Now you can delete all the resources docker has stored on the btrfs storage driver.

docker system prune -f

Yes, that was everything. Now you have your images backed up. Follow the instructions to use the overlay2 storage driver.

After you have changed the storage driver, here's how to load your images back. Run

docker image load -i docker-image-export.tar

Verify that you have all your images by running docker images. That is it.

I hope this was helpful. Cheers.