A Quick Reference
Docker Compose makes it simple to orchestrate a multi-container development environments. Below is a streamlined setup I used for a TYPO3 project. This post serves as a personal reference for future projects.
The Setup
Put this in a .yaml
file:
services:
web:
image: webdevops/php-apache:8.1
container_name: typo3-web
ports:
- "8080:80"
volumes:
- .:/app
working_dir: /app
environment:
- PHP_DISPLAY_ERRORS=1
- PHP_MEMORY_LIMIT=512M
db:
image: mariadb:10.5
container_name: typo3-db
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: typo3_db
ports:
- "3306:3306"
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
Web Service: PHP + Apache
- Image:
webdevops/php-apache:8.1
– A PHP 8.1 image with Apache preconfigured (update to release compatible with T3 installation) - Ports: Maps container port
80
to host port8080
for access athttp://localhost:8080
. - Volumes: Mounts the current directory to
/app
for real-time file changes. - Environment:
PHP_DISPLAY_ERRORS=1
for debugging.PHP_MEMORY_LIMIT=512M
for performance.
DB Service: MariaDB Database
- Image:
mariadb:10.5
– A stable MariaDB version back then (Update to current release) - Environment: Sets root password and initializes
typo3_db
database. - Ports: Maps MariaDB port
3306
to host for database access. - Volumes: Persists data using the
db_data
volume.
Persistent Volume
db_data
Volume: Stores database files persistently across container restarts.
Running the Setup
Run the following command to start the environment:
docker-compose up -d
(-d
is for detached mode, which starts the process in another shell, keeping the parent shell interactive)
This brings up the PHP-Apache server and MariaDB database with the defined configurations.
And that’s it for now 😊.