Skip to content
Technomantus Corvi edited this page Sep 5, 2026 · 1 revision

Docker

An app container (PHP-FPM), Nginx as a reverse proxy, and a database container (MySQL/MariaDB or PostgreSQL — choose one in docker-compose.yml). Apache is intentionally excluded; .htaccess already covers shared-hosting deployments.

Starting the stack

docker compose up -d --build     # uses docker-compose.override.yml automatically if present
docker compose logs -f app
docker compose down               # stop
docker compose down -v            # stop + wipe volumes (deletes the database)

App reachable at http://localhost:8050 (adjust the port in the nginx service if needed).

Creating the table inside the container

The db container starts empty — create tables manually the first time, inside the container:

# MySQL/MariaDB
docker compose exec db mysql -u root -p"${DB_ROOT_PASSWORD:-changeme}" "${DB_NAME:-tanuki_db}"

# PostgreSQL
docker compose exec db psql -U "${DB_USER:-tanuki}" -d "${DB_NAME:-tanuki_db}"

Then run your CREATE TABLE statements as usual. Alternative: mount a docker/init.sql at /docker-entrypoint-initdb.d/init.sql in the db service — it runs automatically the first time the data volume is empty.

.env for Docker

DB_HOST=db   # service name, not "localhost" — containers resolve each other by name

Development vs. production builds

docker-compose.override.yml loads automatically alongside docker-compose.yml and adds PHPUnit + Xdebug (INSTALL_DEV_DEPS=true, APP_DEBUG=true). For production, exclude it:

docker compose -f docker-compose.yml up -d --build

Running PHPUnit inside the container

docker compose exec app ./vendor/bin/phpunit

Debugging with Xdebug inside Docker

Unlike local Xdebug, your editor runs on the host, not the container — Xdebug needs to reach out.

Already configured via docker-compose.override.yml:

environment:
  - XDEBUG_MODE=debug
  - XDEBUG_CONFIG=client_host=host.docker.internal client_port=9003
extra_hosts:
  - "host.docker.internal:host-gateway"

launch.json needs pathMappings here (unlike local dev) since the container's project path differs from your host's:

{
    "configurations": [{
        "name": "Listen for Xdebug",
        "type": "php", "request": "launch", "port": 9003,
        "pathMappings": { "/var/www/html": "${workspaceFolder}" }
    }]
}

Troubleshooting: docker compose exec app getent hosts host.docker.internal — if that fails, on old Docker Engine (Linux, no Docker Desktop) use the docker0 bridge IP (ip addr show docker0) as client_host instead.

Clone this wiki locally