Search code examples
dockerdockerfile

How to copy files in docker container to local?


I have a program which creates files and i need to create these files to user into a project-folder outside of container. When im using docker container these files creates inside of container, but i need to share them to users outside of container to local of my folder with a project.

i saw docker cp but im need for an automatically copying solution.


Solution

  • You can achieve by docker volume & bind mount, where you will be able to bind a host volume to container volume. You need to make sure the permission while doing volume bind is correct. You can refer to the following document:

    1. https://docs.docker.com/engine/storage/volumes/ -as in the comment and
    2. https://docs.docker.com/engine/storage/bind-mounts/