Member-only story

Running PHP with Docker: My Symfony Setup

My proven Docker strategy for deploying Symfony apps with Apache, MySQL, and OpenSearch.

3 min readApr 20, 2025
Photo by Rubaitul Azad on Unsplash

Over the years, I’ve worked on a variety of PHP applications — from simple APIs to large-scale Symfony-based platforms. One of the consistent challenges has been ensuring a consistent development and production environment. Enter Docker.

In this article, I’ll walk you through how I run PHP applications in Docker, focusing on Symfony projects. I’ll share my personal setup using a Dockerfile and docker-compose that’s been hardened through production use.

🔓 Not a Medium member yet? Click here to access this article for FREE!

Why Docker for PHP?

PHP runs everywhere — but that’s both a blessing and a curse. Different environments can lead to bugs that are hard to reproduce. Docker solves this by letting you define your infrastructure as code. No more “it works on my machine” excuses.

The Dockerfile

Here’s the Dockerfile I use for Symfony apps. It’s optimized for production and includes some Symfony-specific tweaks:

FROM php:8.4-apache-bookworm AS app_php

ENV TZ=Europe/Berlin
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV…

--

--

Roman Huliak
Roman Huliak

Written by Roman Huliak

Full Stack Developer with 15 years of experience in ERP systems, skilled in leadership, analysis, and end-to-end development.

Responses (1)