A Docker-based local development stack for PHP applications using Nginx, PHP-FPM, MariaDB, Redis, and an optional management UI.
- Docker Engine 20.10+ with the Compose plugin
- Git
- (macOS only, optional) Homebrew for the dnsmasq helper script
-
Clone the repository:
git clone https://github.com/cerberos-dev/crb-dock.git cd crb-dock -
Copy the example environment file and adjust it to your machine:
cp .env.example .env
-
Review the important variables in
.env:APPLICATION— path to your project code on the host.PHP_VERSION—7.4(legacy WordPress),8.1,8.2,8.3, or8.4.MARIADB_*— database name, user, and passwords (only used on first start).
-
Build and start the stack:
docker compose up -d
Or use the included Makefile:
make start
-
Verify the services are healthy:
docker compose ps
The included Makefile wraps the most common tasks:
make help # show all commands
make build # build or rebuild all services
make start # start the stack
make stop # stop the stack
make restart # restart all services
make down # stop and remove containers
make logs # follow logs
make shell-ws # shell into the workspace container
make shell-php # shell into the php-fpm container
make shell-db # open a MariaDB root shell
make reset-db # destroy and recreate the MariaDB data directory-
Go to
nginx/sites/and copy an example config:cp nginx/sites/sample.conf.example nginx/sites/my-project.conf
-
Edit the config to match your project (
server_name,root, logs, etc.). -
If you are not using a local DNS resolver, add the domain to your hosts file:
127.0.0.1 my-project.localhost -
Reload Nginx to pick up the new site:
docker compose exec nginx nginx -s reload
A default self-signed certificate is generated on first start in nginx/ssl/.
It includes SANs for crb-dock.localhost, crb-dock.local, crb-dock.crb,
localhost, and 127.0.0.1.
-
Stop all services:
docker compose down
-
Change
PHP_VERSIONin.envto the desired version. -
Rebuild the PHP-FPM image:
docker compose build php-fpm
-
Start the stack again:
docker compose up -d
PHP 7.4 is kept for older WordPress sites. It uses a dedicated legacy
Dockerfile (php-fpm/Dockerfile-7.4) because it requires a different base
image, older system libraries, and extensions such as IonCube and mcrypt that
are not supported on modern PHP versions.
PHP 7.4 reached end-of-life in November 2022. Only use it for maintenance of existing projects and avoid it for new work.
Back up the database:
docker compose exec mariadb mariadb-dump -u root -p"$MARIADB_ROOT_PASSWORD" \
"$MARIADB_DATABASE" > backup.sqlRestore a backup:
docker compose exec -T mariadb mariadb -u root -p"$MARIADB_ROOT_PASSWORD" \
"$MARIADB_DATABASE" < backup.sqlDestroy and recreate the database volume:
make reset-dbThe MariaDB environment variables only affect the first initialization of an empty data directory. Resetting the database is required to change them.
For easier local domain resolution you can use the helper in tools/setupDNS.sh.
It is currently written for macOS + Homebrew dnsmasq.
On Linux you can instead:
- Edit
/etc/hostsmanually. - Use a user-space DNS resolver such as
dnsmasq. - Use the
.localhostTLD, which most modern browsers resolve to127.0.0.1.
Portainer is disabled by default. To start it:
make management
# or
docker compose --profile management up -dThen open http://localhost:9000.
Service images are pinned to tested versions in their Dockerfiles. To update,
change the tag in the relevant Dockerfile, rebuild, and verify:
docker compose build <service>
docker compose up -d-
Port 80/443 is already in use: change
NGINX_HOST_HTTP_PORTandNGINX_HOST_HTTPS_PORTin.envto higher ports such as8080and8443. -
Permission errors in mounted volumes: ensure
WORKSPACE_PUIDandWORKSPACE_PGIDin.envmatch your host user (id -uandid -g). -
Services fail health checks: inspect logs with
make logsand check that all required environment variables are set in.env. -
Changes to
.envare ignored for running containers: most variables are only read at container creation. Recreate the container withdocker compose up -d --force-recreate <service>.