Skip to content

Instantly share code, notes, and snippets.

@tomplex
Last active September 28, 2023 15:22
Show Gist options
  • Save tomplex/ecd51368cf75c5bc36341ad8ce825a73 to your computer and use it in GitHub Desktop.
Save tomplex/ecd51368cf75c5bc36341ad8ce825a73 to your computer and use it in GitHub Desktop.
Mount a docker image's contents to your local machine for inspection
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