Docker Community Forums

Share and learn in the Docker community.

Is there a way to copy a file from an image to the local filesystem without running a container?


(Mick Killianey) #1

Our team has been building docker images that contain metadata manifest files. Ideally, before we run an image, we’d love to inspect that metadata file, using something like:

docker cp image-name:/path/to/manifest /local/path/to/manifest

so that we can make decisions about how we want to run it. Of course it’s possible to get at our files by creating a throwaway container:

docker run --name temp-container-name image-name /bin/true
docker cp temp-container-name:/path/to/manifest /local/path/to/manifest
docker rm temp-container-name

But is there a way to copy a file directly from an image without first creating a container?


(Yc993) #2

Does anyone have an answer?


(Sam) #3

don’t know… but you can drop one step, the docker rm , if you do the docker run with --rm as a parm

and https://blog.ropnop.com/plundering-docker-images/
and http://blog.oddbit.com/2015/02/13/unpacking-docker-images/


(Gary K) #4

I’m only reading articles at the moment, but the OCI toolset and/or similar tools (looking at umoci atm) may do what you want.

I’ve only spent ~ 5 minutes looking at this and it looks like there are methods to ‘unpack’ an image. Wether or not they allow you to pull a single file though … idk.

Please let me know how it goes if you try them. It will take me a while before I’ll be able to compile/run/test the tools myself. (I have a similar use-case)


(Wh00) #5

Use docker create to create the throwaway container without running it. then run your docker cp. Still creates a container though.