Last active
October 18, 2016 05:14
-
-
Save istepanov/f1585f10bd77c34263cfc54ffa77de29 to your computer and use it in GitHub Desktop.
Copy host folder to a Docker volume (preserving all file permissions and ownership)
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
#!/bin/bash | |
# this is the source folder. We want to copy its content to a Docker volume. | |
SRC_PATH='/opt/docker/gitlab/data' | |
# this is target volume name. Assuming it's not been created yet. | |
VOLUME_NAME='gitlab-data' | |
tar Ccf $(dirname $SRC_PATH) - $(basename $SRC_PATH) | docker run -i --rm -v $VOLUME_NAME:/data debian tar Cxpf /data - --strip-components=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment