Do not mount volume on build

I want to keep DB data inside the dev container to be able to distibute a full development application with sample real life data.

I have read this topic many times and usually it stops at someone having to give a realy good example from the real worls. I have it.

I have some dev boxes and I do a DB update via my CI server. The CI server builds all my images. Ine of those images is a percona db server.

This is how I do it today
I build a base image for percona. I do this by copy the files and Dockerfile from the percona repo. Then I comment out the VOLUME ["/var/lib/mysql", "/var/log/mysql"] line.

Then when I build the docker container and restore a sample DB to this container the mysql data say inside the container. Then when I use this container in the application I configure a volume in the docker.compose file so the data from the container is copied to the local host as persistend data.

If the developer need to reset to a clean sample DB they just run docker-compose down and delete the volume. Nest time the docker-compose up is run a new DB is copied locally.

So what is the problem here?
The problem is percona, mysql and postgres images change so often and they remove install packages from their repos. So if I try to build a percona image from the docker file I fetched at the beginning it will fail because the source code is not availeble at this version for percona any more. Then I need to update my docker file. This is not good because installing the latest and run yum update is important.

What is my solution?
What I think might be a solution to this is some kind of tag or parameter to use on build where we do not mount the defined volumes.

Like docker build --no_mount="/var/lib/mysql" or somthing like this.

I am pretty sure someone have other ideas. The point is to be able to keep data inside the container on build when we use pre built images like parcona, mysql, postgresql, mongoDB etc…

Or do any one know another way of acheiving this.
Alternativly I will have to build my own base images for DB services to.