Below you will see the statement I used to deploy a Wordpress as db mariadb (mysql); I shared it to you, cos I’ve been looking out for a good .yml statement piece, but some of them are older or put other set frontend as nginx, etc. I did a simple and easier deployment statement, so here we have:


version: '3.3'

services:
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     volumes:
       - ./html:/var/www/html
     ports:
       - "8080:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: password
     links:
       - db
     depends_on:
       - db

   db:
     image: mariadb:10.5.4-focal
     volumes:
       - ./db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: SECRET
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: password
     ports:
       - "3306:3306"

You can switch the local mount to volume mount it will depend of you design.

Hope it can be useful to you