Skip to content

Instantly share code, notes, and snippets.

@mathewdgardner
Created March 1, 2016 02:55
Show Gist options
  • Save mathewdgardner/b8b834b9d94da898b5df to your computer and use it in GitHub Desktop.
Save mathewdgardner/b8b834b9d94da898b5df to your computer and use it in GitHub Desktop.
Save / load compressed docker images
#!/bin/bash
# Save docker images
ds() {
docker images | \
cut -d ' ' -f 1 | \
tail -n +2 | \
xargs -t -n 1 -I {} -P 4 \
sh -c 'docker save {} | bzip2 > $(echo "{}" | sed "s/^.*\///").tar.bz2'
}
# Load docker images
dl() {
ls *.bz2 | \
xargs -t -n 1 -I {} -P 4 \
sh -c 'bzip2 -dc {} | docker load'
}
@kebyn
Copy link

kebyn commented Sep 6, 2019

#!/bin/bash

# Save docker images
ds() {
  docker images --format {{.Repository}}:{{.Tag}} | xargs -t -n 1 -I {} -P 4 sh -c 'docker save {}  > $(echo "{}" | sed "s/^.*\///").tar.gz'
}

# Load docker images
dl() {
  ls *.tar.gz | xargs -t -n 1 -I {} -P 4 sh -c 'docker load -i {}'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment