Here is how you can make mysqldump on container that created from mariadb image
docker exec -it root_mysql_1 sh -c 'exec mysqldump -p"$MYSQL_ROOT_PASSWORD" wordpress' > /backup/wordpress-$(date +\%F).sql
This command does the following:
- run mysqldump command inside your mysql container
- use root password from MYSQL_ROOT_PASSWORD env
- dump to a backup file with the date of today