Save database files to a different location, outside mysql container

I am using Devilbox v1.9.2, and I am trying to configure it to save MySQL Data directory into a different location. I mean, according my review if I rebuild the Mysql container the databases are lost, then I want to know if is posible to indicate a different MySQL Data directory, outisde mysql container, in order to persist the database files.
Please let me know if I am not clear with this description, and thanks for the attention to this message.

Databases persist. They store their data in a Docker volume. Only if you delete the Docker volume it is lost. Different versions of MySQL/MariaDB/Percona all use their own volume, so changing from one version to another will have different data dirs (Docker volumes)