Last active
March 18, 2021 12:33
-
-
Save mrsarm/6713bfd973c2338ddada12e53487886f to your computer and use it in GitHub Desktop.
docker-volume-cp script: copy one Docker volume content to a new one
This file contains 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 sh | |
if [ "$#" -ne 2 ]; then | |
echo "docker-volume-cp: copy one Docker volume content to another" | |
echo | |
echo "Use: docker-volume-cp VOL_SOURCE VOL_DEST" | |
echo | |
echo "NOTE: if VOL_DEST does not exist, docker-volume-cp creates it first" | |
exit 2 | |
fi | |
docker volume create --name "$2" | |
docker run --rm -it -v "$1:/from" -v "$2:/$2" alpine sh -c "cd /from ; cp -av . /$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment