Docker - how can I copy a file from an image to a host?

前端 未结 8 716
庸人自扰
庸人自扰 2020-12-02 05:56

My question is related to this question on copying files from containers to hosts; I have a Dockerfile that fetches dependencies, compiles a build artifact from source, and

8条回答
  •  [愿得一人]
    2020-12-02 06:53

    Another (short) answer to this problem:

    docker run -v $PWD:/opt/mount --rm -ti image:version bash -c "cp /source/file /opt/mount/"
    

    Update - as noted by @Elytscha Smith this only works if your image has bash built in

提交回复
热议问题