How can i manage files in my host machine on Docker

126 Views Asked by At

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?

2

There are 2 best solutions below

0
BertC On

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.

0
Sparko Sol On

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/