Skip to content

Instantly share code, notes, and snippets.

@michael-yx-wu
Last active July 26, 2016 21:15
Show Gist options
  • Save michael-yx-wu/6d35bb6235a7374140415f8e599ef958 to your computer and use it in GitHub Desktop.
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.
#!/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