/docker-image-extract

Minimal-dependency shell script to pull and extract all files from an image in Docker Hub

Primary LanguageShellMIT LicenseMIT

The docker-image-extract script pulls and extracts all files from an image in Docker Hub.

It has minimal dependencies that should exist in pretty much any Linux environment, with the possible exception of curl/wget:

  • curl or wget
  • find
  • grep
  • gzip
  • mkdir
  • rm
  • sed
  • sh
  • tar

If you are using BusyBox, version 1.34.0 or later is required, as the wget implementation in earlier versions does not recognize the HTTP 307/308 redirects returned by Docker Hub.

See also

Sample output

$ ./docker-image-extract busybox:musl
Getting API token...
Getting image manifest for library/busybox:musl...
Fetching and extracting layer e4df39e4f349fc83694349a5a94afc8d9857fa66f7421427f3d2463a58d876d3...
Image contents extracted into ./output.
$ ls output
bin  dev  etc  home  root  tmp  usr  var
$ ls -l output/bin/{busybox,ls}
-rwx------ 393 jjlin users 1148648 Apr  7 13:18 output/bin/busybox
-rwx------ 393 jjlin users 1148648 Apr  7 13:18 output/bin/ls