-2

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.

3
  • 2
    You could mount a directory into the container such that when the container writes to those files inside. They are also visible outside. docs.docker.com/engine/storage/volumes Commented Sep 8, 2024 at 7:46
  • 2
    stackoverflow.com/questions/23439126/… Commented Sep 8, 2024 at 7:57
  • If a principal part of your application involves writing local files, or knowing who the local user is, it may be much easier to run directly on the host: containers don't have direct access to the user's home directory or any knowledge of who the host user might be. Commented Sep 8, 2024 at 11:16

2 Answers 2

3

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/
Sign up to request clarification or add additional context in comments.

Comments

3

Thanks you guys for helps!

my solution:

docker run -v $(pwd)/result_folder:/<project_folder>/result_folder <container_name>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.