docker-php-nginx icon indicating copy to clipboard operation
docker-php-nginx copied to clipboard

Mount existing Docker container files to host

Open psycho0verload opened this issue 3 years ago • 1 comments

First of all, I would like to thank you very much for this project. It has helped me a lot. I tried writing my own Dockerfile at Psycho0verload/DirectoryLister and it works.

Directory Lister gives a nice overview of the existing files.

I get the current version to work and now face the challenge that I have to run Directory Lister under /var/www/html/ and at the same time mount /var/www/html so that I can add files there so that they can then be shown in Directory Lister.

If I run the container with

docker run -d -p80:8080 psycho0verload/directorylister

it works but I can't add files easily

If I run the container with

docker run -d -v "`pwd`/directorylister:/var/www/html/" -p80:8080 psycho0verload/directorylister

it foreseeably does not work. When mounting, all files that I previously had in the image there are deleted.

Do you have an idea how I can solve this?

psycho0verload avatar Jun 02 '22 22:06 psycho0verload

Hi @Psycho0verload,

Yes, when you mount a volume from your host system, it overrides everything already in the container at the mount location. What you should try to do is have one folder with the DirectoryLister and a different folder for mounting the files from your host folder. There might be a configuration parameter in DirectoryLister that allows it to look at a different folder?

So you get this;

/var/www/html/ < DirectoryLister sourcecode
/var/www/files/ < Path where DirectoryLister looks at for finding the files

Then you can safely mount /var/www/files/ to your host and it doesn't override the DirectoryLister sourcecode.

TrafeX avatar Jun 05 '22 06:06 TrafeX

I'm going to close this issue due to inactivity. Let me know if you still need help!

TrafeX avatar Sep 06 '22 19:09 TrafeX