Skip to content

Copying things out of a Docker based build #27092

Answered by Simran-B
kaihendry asked this question in Actions
Discussion options

You must be logged in to vote

With Docker in general, the following ways to get files out of a container come to mind:

  • Run the docker cp command

    Copy files/folders between a container and the local filesystem

    This would need to be run on the host system, however.

  • Mount a folder of the host system into the container as a volume, then copy files to the mounted folder inside the container.

  • Use a multi-stage Docker image to only leave the files you are interested in in the container at the end of the image building process. If you want to copy out files when running this image later, then this option is irrelevant.

    FROM <base-image> AS build
    ...
    FROM scratch AS artifacts
    COPY --from=build /path/to/file /
    

    Afterwar…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants