Last active
September 28, 2023 15:22
-
-
Save tomplex/ecd51368cf75c5bc36341ad8ce825a73 to your computer and use it in GitHub Desktop.
Mount a docker image's contents to your local machine for inspection
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
IMAGE_REGISTRY="" | |
IMAGE_NAME="image" | |
IMAGE_TAG="tag" | |
VOLUME_NAME="${IMAGE_NAME}-${IMAGE_TAG}" | |
# Contents will be accessible in /tmp/IMAGE_NAME-IMAGE_TAG | |
docker volume create \ | |
--driver local \ | |
--opt type=none \ | |
--opt device=/tmp/$VOLUME_NAME \ | |
--opt o=bind \ | |
$VOLUME_NAME | |
docker run -it --rm --mount source=${VOLUME_NAME},target=/app "${IMAGE_REGISTRY}${IMAGE_NAME}:${IMAGE_TAG}" /bin/bash | |
# ctrl-c when you're done | |
docker volume rm $VOLUME_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment