Docker Compose Generator
Assemble a docker-compose.yml from common services (MySQL, Postgres, Redis, Laravel, Node...) with ports, environment and volumes, in your browser.
1 of 1 service ready
mysqlmysql:8.4
Generated files (1)
No issues
Processed locally in your browser. Your data never leaves your device.
About this Docker Compose generator
Add services from the preset list (MySQL, PostgreSQL, Redis, Mailpit, a Laravel or Node app, ...) or build one from scratch, edit ports, environment variables, volumes and which services depend on which, and get a working docker-compose.yml. Presets come filled with the environment variables each image actually needs to start (a database root password, for instance), not just an empty shell.
A worked example
Adding the Laravel app preset, then the MySQL 8 preset, then ticking mysql under the app service's Depends on, produces:
services:
app:
image: "php:8.3-fpm"
environment:
APP_ENV: "local"
volumes:
- ".:/var/www/html"
depends_on:
- mysql
restart: unless-stopped
mysql:
image: "mysql:8.4"
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: "secret"
MYSQL_DATABASE: "app"
volumes:
- "mysql_data:/var/lib/mysql"
restart: unless-stopped
volumes:
mysql_data: {}Note that mysql_data (a named volume, not a path) is declared once more at the bottom under volumes: — Compose requires every named volume a service uses to also be declared there, and it is added for you automatically.
How to use it
- Pick a preset from the dropdown and click Add, or add a blank service.
- Fill in or edit the name, image, ports, environment, volumes and restart policy.
- Tick Depends on for services that should start after another (e.g. an app after its database).
- Read the diagnostics: they explain anything left out, such as an incomplete field or a duplicate name.
- Copy or download the file.
Presets included
- Databases: MySQL, MariaDB, PostgreSQL, MongoDB
- Cache: Redis
- Mail: Mailpit (catches outgoing mail locally, with a web UI)
- Web/app: Nginx, a Laravel app (PHP-FPM), a Node.js app
- Admin: phpMyAdmin, Adminer
Frequently asked questions
- Why does the MySQL/Postgres preset already have a password set?
- Those images refuse to start at all without a root/superuser password (or an explicit opt-out most people do not want), so the preset fills in a placeholder one and a database name. Change it before using the file for anything beyond local development.
- What is the difference between a named volume and a bind mount?
- A source that looks like a path (starts with ./, / or ~) is a bind mount: a folder on your machine, mounted straight into the container — used here for source code (./ into /var/www/html) so edits are picked up immediately. Anything else (mysql_data, redis_data, ...) is a named volume: storage Docker manages itself, declared once at the bottom of the file under volumes:, so it survives a container being removed and recreated.
- Why is a dollar sign in a value doubled to $$ in the output?
- Docker Compose reads $VAR and ${VAR} in every value as a variable to substitute, even inside environment: and command:. A literal dollar sign you actually want the container to see (part of a password, for example) has to be written $$ or Compose would try to substitute it. This is done for you automatically.
- Can two services share a database?
- Yes: point both at the same service name as the host (for example DB_HOST=mysql), and use Depends on so Compose starts the database first. Compose gives every service its own hostname on a shared network automatically, so containers reach each other by service name, not localhost.
- What happens to an incomplete field, like a port with no container side?
- It is left out of the file, never guessed at — filling in a plausible-looking default for a field you left blank could produce a file that runs but does something you did not intend. Check the diagnostics panel; it explains exactly what was left out and why.