Production-ready Docker images for PHP. Optimized for Laravel, WordPress, and more.

Hey folks,

Since last fall, I spent over 500 hours revamping our infrastructure to use Docker + Gitlab CI for our deployments. During this process, I also wrote my own PHP images and made them freely available on Github:


# Why these images and not other ones?

**These images are used in production**

What you run in development is what you should run in production. These images are designed and hardened to run on the open, wild Internet. I used a lot of knowledge that I gained in /u/fideloper's "Shipping Docker" course and incorporated that knowledge into these images.

**Say goodbye to Supervisor configs!**

PHP is unique where it requires PHP-FPM and a web server (like NGINX or Apache) to be available in a single container. Many people cringe reading that, but you need to do this if you want your entire application to be packaged and versioned in a single image.

Some images use Supervisor, but Supervisor was not specifically designed for containers. Instead, I chose [S6 Overlay]( which is designed from the ground up to run within the lifecycle of a container. This gives us a clearer picture if our service is running and is healthy.

**Stupid-simple configurations for Laravel Horizon, Queues, and Task Schedulers**

Since S6 Overlay replaces Supervisor, this means you don't even need to worry about supervisor configs for Laravel Horizon, Queues, or Task Schedulers. It' just as [simple as passing your command](

**Automated tasks executed on start up**

I optimized common tasks at start up that you can enable/disable depending on your needs:

1. Automated database migrations
2. Automated storage linking

**Tons of customizations with environment variables**

I have every environment variable fully documented so you can easily customize the image at a per-app basis.

# Real-life working example

Sharing these images is just one slice of the entire picture when it comes to the DevOps process. I also have a video available where I give a very high-level overview of what "development to production" looks like: [](

I hope you find this resource as a solid contribution to the Laravel Community and helpful for your own projects. As always, if you have any questions or constructive feedback, I would love to hear your thoughts!

If you like what I have, there are a a lot of other tools that I wrote that I'd love to share with you to make your app building process easier.

Keep on building great things! 😎

4 thoughts on “Production-ready Docker images for PHP. Optimized for Laravel, WordPress, and more.”

  1. Using the same image for both production and development sounds great, but what about xdebug? I don’t see it mentioned in the readme.

  2. I really like how you’ve structured these projects; thank you for your contribution to the community! We currently use our own multi-stage prod/dev build for our Laravel API but I’m going to play around with transitioning to these images.

  3. how do you handle with the stateful stuff like storage session and database? i also want to dockerize my own project. I am also studying k8s.

    my problem is the scalability on those user data. when the container is hosted on single machine, it is pretty simply. When i want it goes HA/on multiple nodes, it becomes complicated.

    For example, i need the persistent storage need to be replicated between the nodes. It is too hard to do it on container comparing to VM.

    And my solution is moving those stateful data away from the container. For example building your own mariadb, redis, file system cluster or just use cloud services like rds efs on aws. Prevent from using any local volume, db, queue, redis with docker. Just config your container to connect to those services so i can scale up your application easily by just create more replica

    Is it a normal way to do that?


Leave a Comment