WordPress + MySQL in one cardinal up
Declare a two-container stack in cardinal.toml — database first, then WordPress — and start it with a single command.
Most sites are more than one container. cardinal's compose support starts a
whole stack from a single cardinal.toml, respecting dependencies — the
database comes up first, WordPress waits for it.
1. Write cardinal.toml
[container.db]
image = "mysql:8"
ports = ["3306:3306"]
env = {
MYSQL_ROOT_PASSWORD = "root_pass123",
MYSQL_DATABASE = "wordpress",
MYSQL_USER = "wordpress",
MYSQL_PASSWORD = "wp_pass123",
}
volumes = ["db_data:/var/lib/mysql"]
restart = "always"
[container.wordpress]
image = "wordpress:latest"
ports = ["8080:80"]
env = {
WORDPRESS_DB_HOST = "db:3306",
WORDPRESS_DB_USER = "wordpress",
WORDPRESS_DB_PASSWORD = "wp_pass123",
WORDPRESS_DB_NAME = "wordpress",
}
volumes = ["wp_data:/var/www/html"]
restart = "always"
depends_on = { db = "service_healthy" }
Two details worth noting:
WORDPRESS_DB_HOST = "db:3306"— containers reach each other by name on
the cardinal0 bridge, so WordPress talks to the db container directly.
depends_on = { db = "service_healthy" }— cardinal waits for MySQL's
healthcheck before starting WordPress, so there's no race on first boot.
2. Start the stack
cardinal up
cardinal auto-detects cardinal.toml, creates both containers in dependency
order, and pulls the images if needed. Verify:
cardinal ps
3. Install WordPress
Open http://your-server-ip:8080 and run through the installer. Content and
plugins persist in the wp_data volume.
4. Day-to-day
cardinal up myapp # start only one service
cardinal down # stop + remove the stack (volumes stay)
cardinal volume ls # db_data / wp_data are still there
cardinal logs -f wordpress # follow logs
Want to expose it on 443 with TLS later? Point a Caddy container at
wordpress:80 and let it terminate HTTPS for you.