The API Platform Docker Setup in Depth
The API Platform Docker Setup in Depth
~14 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
Before starting actual API development, a detailed look at compose.yaml – important for understanding deployment LATER (chapter 98).
compose.yaml in detail (shortened)
services:
php:
build:
context: .
target: frankenphp_dev
depends_on:
- database
environment:
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80
DATABASE_URL: postgresql://app:!ChangeMe!@database:5432/app?serverVersion=16&charset=utf8
MERCURE_URL: https://php/.well-known/mercure
volumes:
- ./api:/app
ports:
- target: 443
published: 443
database:
image: postgres:${POSTGRES_VERSION:-16}-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-app}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
volumes:
- database_data:/var/lib/postgresql/data
volumes:
database_data:FrankenPHP: the modern PHP application server
target: frankenphp_dev uses FrankenPHP – a modern PHP application server that combines Caddy (a web server WITH automatic HTTPS) AND the PHP interpreter in ONE process. Unlike the classic approach (Nginx/Apache PLUS a separate PHP-FPM process), EVERYTHING runs in ONE container here – simpler to operate, often more performant too.
Understanding the volumes mapping
./api:/app mirrors your LOCAL api/ directory into the container – changes to your code (edited on your machine with your editor) are IMMEDIATELY visible in the container, WITHOUT rebuilding the image. That's EXACTLY why local development stays this smooth despite Docker.
Environment variables: .env vs. compose.yaml
DATABASE_URL is set DIRECTLY in compose.yaml HERE – EXACTLY the same purpose as .env in the Symfony course (chapter 4), just defined at the Docker level instead of the PHP level. Symfony reads this environment variable EXACTLY the same way as before, regardless of WHERE it comes from.
Achtung: !ChangeMe! as the default password is DELIBERATELY, obviously insecure – for PRODUCTION deployments (chapter 98), this value MUST be replaced with a real, generated secret, EXACTLY like APP_SECRET in the Symfony course.
Viewing logs
docker compose logs php --follow
docker compose logs database --follow--follow (short: -f) streams new log lines live – invaluable for debugging, since Symfony's own var/log/ directory (chapter 4 of the Symfony course) sits INSIDE the container and isn't directly visible from the host without this command.
Logging into the container
docker compose exec php bashTipp: For longer debugging sessions, an INTERACTIVE shell in the container is often more convenient than prefixing EVERY individual command with docker compose exec php ... – after exit you're back on your host system.