22

I can see that it's possible to insert a file into a Docker container via insert:

docker insert IMAGE URL PATH

Is there a way to fetch the contents of a file in a Docker container and save them somewhere on the host operating system? I'd like to extract the value of a configuration file and store it on my host operating system.

2

1 Answer 1

37

Depends on which version of the docker tool you're using:

  • The current version has an ordinary 'cp' command, according to cp doc v0.6.3:

    Usage: docker cp CONTAINER:PATH HOSTPATH
    Copy files/folders from the containers filesystem to the host
    path. Paths are relative to the root of the filesystem.

  • For older version, you may consider to use 'export' as from export doc v0.5.3:

    Usage: docker export CONTAINER
    Export the contents of a filesystem as a tar archive

(There may also be other options, based on capabilities of your container.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .