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

前端 未结 8 729
庸人自扰
庸人自扰 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 07:01

    You could bind a local path on the host to a path on the container, and then cp the desired file(s) to that path at the end of your script.

    $ docker run -d \
      -it \
      --name devtest \
      --mount type=bind,source="$(pwd)"/target,target=/app \
      nginx:latest
    

    Then there is no need to copy afterwards.

提交回复
热议问题