This docker-compose.yml does a healtheck for mariadb and starts up wordpress when the database is ready
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
depends_on:
db:
condition: service_healthy
volumes:
- wordpress:/var/www/html
db:
image: mariadb:11.3
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
healthcheck:
test: [
"CMD",
"healthcheck.sh",
"--su-mysql",
"--connect"
]
interval: 10s
timeout: 10s
retries: 3
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
Ещё видео!