Skip to content

Instantly share code, notes, and snippets.

@w-k-s
Created February 14, 2025 18:36
Show Gist options
  • Save w-k-s/a5d067772b58bbba1a39cbac47abe437 to your computer and use it in GitHub Desktop.
Save w-k-s/a5d067772b58bbba1a39cbac47abe437 to your computer and use it in GitHub Desktop.
Extracting files from Docker Images
  1. View Files in Docker Image

    brew install dive
    dive grycap/cowsay:latest
    

Find the folder of interest from dive (you can use control-M to hide modified files, control-R to hide removed files, control-B to hide file attribites, so that you only see files added to the docker image). See commands here

  1. Download files from the docker image

Once you know which file you want to download e.g. /usr/share/nginx/html.

brew install crane
mkdir /tmp/extracted_html
crane export grycap/cowsay:latest - | tar -xvf - -C /tmp/extracted_html usr/share/nginx/html

In this case, the contents of /usr/share/nginx/html will be copied to /tmp/extracted_html on the host machine. Note, you need to exclude the root / when specifying the path in the docker image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment