0

I'm running a custom Docker image based on the official php-fpm image, with just minor tweaks. Inside the host machine I have a folder containing some images I would like to server, so I am running the container and binding the host image folder to a folder in my container like /home/host/images:/var/www/storage/images. This goes well and if I bash into the container I see the files there.

My problem comes when I symlink the folder from the public folder in the container like ln -s /var/www/storage/images /var/www/public/images. The link seems correct and I can navigate there using the shell and see for example my test.png image, but whenever I try to server any image for example https://my-web-app.com/images/test.png I get a 404.

However, from inside the containers shell I've created another folder like /var/www/storage/images2 and then moved test.png and then updated my link like ln -s /var/www/storage/images /var/www/public/images2 and then tested https://my-wen-app.com/images/test.png and it works!

Why can't I link my bound folder but I can link this new folder that I just created? Is there anything else to do when binding to allow this link to work?

namelivia
  • 2,657
  • 1
  • 21
  • 24
  • Does this answer your question? [Mount host directory with a symbolic link inside in docker container](https://stackoverflow.com/questions/38485607/mount-host-directory-with-a-symbolic-link-inside-in-docker-container) – Stefan Golubović Mar 15 '20 at 01:18
  • Thanks for the answer! I found the solution and was not related to the symlink. – namelivia Mar 15 '20 at 12:00

1 Answers1

0

I finally found out the cause. The symlink was working perfectly, the problem was that the container schema was: one container running php-fpm and another container running nginx the main folder was being bound to both containers but the images folder was just mounted to the php-fpm container so when the nginx container was asked for the images was not finding anything because it had no visibility of this volume.

namelivia
  • 2,657
  • 1
  • 21
  • 24