TrafeX / docker-php-nginx

Docker image with PHP-FPM 8.3 & Nginx 1.26 on Alpine Linux
https://hub.docker.com/r/trafex/php-nginx
MIT License
1.37k stars 736 forks source link

Mount existing Docker container files to host #95

Closed Psycho0verload closed 2 years ago

Psycho0verload commented 2 years ago

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?

TrafeX commented 2 years ago

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 commented 2 years ago

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