Last active
July 26, 2016 21:15
-
-
Save michael-yx-wu/6d35bb6235a7374140415f8e599ef958 to your computer and use it in GitHub Desktop.
Until Docker native can automatically do this, use this script to reclaim free space from your Docker.qcow2 file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -o pipefail | |
function qcow2_size() { | |
wc -c Docker.qcow2 | awk '{print $1}' | |
} | |
cd ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux | |
echo "Bytes before shrink: $(qcow2_size)" | |
/Applications/Docker.app/Contents/MacOS/qemu-img convert -O qcow2 Docker.qcow2 Docker2.qcow2 | |
mv Docker2.qcow2 Docker.qcow2 | |
echo "Bytes after shrink: $(qcow2_size)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment