Last active
October 22, 2025 11:56
-
-
Save lhns/04e2ed582d89ae27e3da05eae0dc5fae to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
| copy_to_volume() { | |
| src="$1" | |
| dst="$2" | |
| volume=$(echo "$dst" | cut -d':' -f1) | |
| path=$(echo "$dst:" | cut -d':' -f2) | |
| docker volume create "$volume" | |
| container_id=$(docker create -v "$volume:/vol" "$(echo -e 'FROM scratch\nENTRYPOINT ["/"]' | docker build -q -)") | |
| err=0 | |
| docker cp "$src" "$container_id:/vol/${path#/}" >/dev/null || err=$? | |
| docker rm "$container_id" >/dev/null | |
| return "$err" | |
| } | |
| copy_to_volume "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment