skip to Main Content

can’t access images inside /public/storage
i have done php artisan storage:link

the files are visible when using my local environment but when switching to Docker environment with the same code, i can’t access them (not found)
my files owner is the same as in my docker config

i test it by visiting http://127.0.0.1:8000/storage/test.png

where test.png is inside public/storage

I have 3 services inside my docker-compose file

  1. Nginx
  2. PHP
  3. MYSQL

I think the problem from permissions but i can’t figure out the solution

2

Answers


  1. Chosen as BEST ANSWER

    if anyone faced the same issue.
    i managed to solve this by removing the symlink created by laravel and make my own one from my nginx container based on the real path inside my container


  2. As far as I know, each docker has an IP address. So, you have to start the server with the IP address of docker container. However, to avoid errors from docker’s dynamic IP address, you use 0.0.0.0 instead of the IP address of docker because 0.0.0.0 means all IPv4 addresses on the local machine. To resolve your issue, you use the following command in docker.

    php artisan serve --host 0.0.0.0
    

    Note:


    Maybe you will get another error, let me know if you meet them.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search