Skip to content

Instantly share code, notes, and snippets.

@hiroara
Created January 17, 2018 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroara/4204c39be9e988bcf8ec155d591dafaf to your computer and use it in GitHub Desktop.
Save hiroara/4204c39be9e988bcf8ec155d591dafaf to your computer and use it in GitHub Desktop.
Export a docker volume
#!/bin/bash
IMAGE=${IMAGE:-alpine:3.7}
TARGET_VOLUME=$1
if [ -z ${TARGET_VOLUME} ]; then
echo "Usage $0 <volume name>"
exit 1
fi
docker run -it --rm \
-v ${TARGET_VOLUME}:/src \
-v ${PWD}:/dest \
${IMAGE} cp -R /src /dest/${TARGET_VOLUME}-$(date +%Y%m%d%H%M)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment