Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marcosdipaolo's avatar

laravel project in a docker container, cannot access my images - 403 forbidden

tried already setting the storage folder ownership to www-data and also my user, i tried chmod -R 7777 storage as well. I also tried setting to www-data the whole /var/www.

I don't know what to try anymore, I don't have this problem in another computer where I have the project. Just cloned this one from gitlab.

A brief extract of the browser's console

Image of Yaktocat

0 likes
11 replies
Wraith's avatar

did u run php artisan storage:link

Sinnbeck's avatar

Can you show the full link to an image?

Do you perhaps have a route that gets hit instead?

Can you access any images in /public?

marcosdipaolo's avatar

First of all I have this app running either in production as local in another computer without any problem whatsoever.

The tipical link looks like this: /storage/img/blog/my-image.png

I can't think of a route interfiering, since everything works ok in other systems.

Sinnbeck's avatar

Try logging in to docker and enter /public/storage

Is it possible?

marcosdipaolo's avatar
root@dbfa4a8adf0e:/var/www/html/public# cd storage
bash: cd: storage: No such file or directory

are you sure you can access a directory through an hyperlink at the terminal?

Sinnbeck's avatar

Works on my own setup with docker. I had similar issues with docker. My problem was the path being different. I created my own symlink which was relative and it worked (yes laravel makes absolute paths)

marcosdipaolo's avatar
root@dbfa4a8adf0e:/var/www/html/public# ls -l
lrwxrwxrwx 1 1000 1000       62 Nov 17 22:53 storage -> /home/marcos/Documents/dev/estudio-de-canto/storage/app/public
marcosdipaolo's avatar

@sinnbeck thanks a lot for your help, you pointed me in the solution's direction, the storage:link must be, of course, created logged into the docker container, i created it outside the it was redirecting to the outsider direction (/home/user/....., not /var/www/html/storage......

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

If you make it relative it works both outside and inside docker ;)

Lykos22's avatar

I am still having this issue getting 403 when accessing the image url on the browser. I have created the symlink using relative path, so lrwxr-xr-x 1 lykos staff 21B Feb 13 15:42 storage@ -> ../storage/app/public and also have added Options +FollowSymlinks in the htaccess file in public/ dir. I can cd and ls the content of public/storage either locally or withing the running php container, but still can't access the image url on the browser.. any further ideas please??

Please or to participate in this conversation.