FireBlade's avatar

Images not showing in Laravel Docker production following this guide: https://docs.docker.com/guides/frameworks/laravel/production-setup/#create-a-dockerfile-for-nginx-production

This is my NGINX production Dockerfile :

This is my PHP-FPM Dockerfile :

However, when I start the Laravel app, images are not showing. I even tried adding an image on the welcome.blade.php file as:

<img src="{{asset('/storage/img/quote.svg')}}" alt="">
    </body>
</html>

but on Chrome Developer tools, it shows error 404. Kindly help...

0 likes
3 replies
simotion's avatar

Bit rusty on Docker, but I'll do my best to help.

Have you verified that the public/storage symlink exists inside the Nginx container, not just the PHP container?

Since you're using separate Nginx and PHP-FPM containers, php artisan storage:link runs in the PHP container — but Nginx is the one serving static files.

In your Nginx Dockerfile you only copy:

COPY --from=builder /var/www/public /var/www/public

That means:

The storage directory is not copied

The symlink created in the PHP container is not present

There is no shared volume between containers

So when the browser requests /storage/..., Nginx simply doesn’t have that path — hence the 404.

You have a few options:

Share the entire project directory as a Docker volume between Nginx and PHP

Build both containers from the same source layer so storage and the symlink exist in both

If these are static assets that ship with your app (like quote.svg), consider placing them directly in /public/img instead of storage

Right now, Nginx has no access to the storage directory, which is almost certainly the issue.

1 like
FireBlade's avatar

I tried rebuilding the NGINX image and I get this error:

Step 6/15 : RUN php artisan storage:link
 ---> Running in a8c64eeb9323
/bin/sh: 1: php: not found

I am considering building the images as you suggest...

simotion's avatar

You're running the php artisan command in the NGINX container instead of the PHP container, that's why you getting the error message.

1 like

Please or to participate in this conversation.