New Symfony 7 project. Target stack: PostgreSQL 16, Redis 7, Apache (not Nginx — personal preference, more on that later). Dev environment: WSL2 on Windows. In theory, Docker + WSL2 has been smooth for a few versions now.
In practice, there are 3 problems that show up systematically on day one, that aren't documented together anywhere, and that waste an hour every time. Here's how to avoid them.
The final stack
The complete docker-compose.yml :
services : app : build : . ports : - " 8080:80" volumes : - .:/var/www/html depends_on : - db - redis environment : DATABASE_URL : " postgresql://app:password@db:5432/touspourris"
db : image : postgres:16-alpine ports : - " 5433:5432" # 5433 on host, not 5432 environment : POSTGRES_USER : app POSTGRES_PASSWORD : password POSTGRES_DB : touspourris volumes : - postgres_data:/var/lib/postgresql/data
redis : image : redis:7-alpine ports : - " 6379:6379"
volumes : postgres_data :
Enter fullscreen mode
Exit fullscreen mode
The detail that matters: the 5433:5432…