Docker Compose for WordPress + MySQL
WordPress with MySQL. The world's most popular CMS, containerized.
php wordpress mysql cms
compose.yaml
services:
wordpress:
image: wordpress:latest
ports:
- target: 80
mode: ingress
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=${WORDPRESS_DB_PASSWORD}
- WORDPRESS_DB_NAME=wordpress
healthcheck:
test:
- CMD
- curl
- -f
- http://localhost/
interval: 30s
timeout: 10s
retries: 3
depends_on:
- db
deploy:
resources:
reservations:
cpus: "0.5"
memory: 256M
restart: unless-stopped
db:
image: mysql:8
ports:
- target: 3306
mode: host
environment:
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
healthcheck:
test:
- CMD
- mysqladmin
- ping
- -h
- localhost
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
reservations:
cpus: "0.5"
memory: 256M
restart: unless-stopped
Services
- wordpress wordpress:latest
- db mysql:8