0

I am using Docker on my Windows machine and i want to copy a directory to another directory in my Windows host. I have a Maven project that does this on Windows using org.apache.commons.FileUtils library and it works just fine. I want to run this Maven project in my Docker container so that i can move files on my Windows via Docker.

When i tried doing it, it gave no error but there was no copy process either. Can i manage files on my host machine with Docker?

  • No. One of the major goals of Docker is that containers _can't_ access the host filesystem, without being given special permission by the operator. Using the `cp` or `copy` command on the host will be much easier than trying to make this work via Docker. – David Maze Nov 14 '22 at 10:24

2 Answers2

0

Most sensible anwwer: You should not want to do this. If you are working in a Container, don't have dependencies to the Host. Having dependencies to the Host contradicts why Docker exists.

But if you insist: You can do this by mapping the directories of the Host inside the Docker Container via Volumes. And then you can copy inside the Docker container.

BertC
  • 2,243
  • 26
  • 33
-1

You can follow this: Docker: How to live sync host folder with container folder?

And learn about docker volumes from here: https://docs.docker.com/storage/volumes/

Sparko Sol
  • 651
  • 1
  • 9