Created
July 21, 2023 07:19
-
-
Save ArloL/050e770cd3ee1f37a386017ddad95ba5 to your computer and use it in GitHub Desktop.
docker copy
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 | |
set -o errexit | |
set -o nounset | |
set -o xtrace | |
CONTAINER_ID_FILE=$(mktemp -u) | |
cleanup() { | |
currentExitCode=$? | |
rm -f "${CONTAINER_ID_FILE}" | |
docker rm "${CONTAINER_ID}" || true | |
exit ${currentExitCode} | |
} | |
trap cleanup INT TERM EXIT | |
IMAGE_ID=$(cat "${1}") | |
docker create \ | |
--cidfile "${CONTAINER_ID_FILE}" \ | |
"${IMAGE_ID}" | |
CONTAINER_ID=$(cat "${CONTAINER_ID_FILE}") | |
docker cp "${CONTAINER_ID}:${2}" "${3}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment