We're heavily using docker for integration testing and to reduce the setup times for the test environment, we'd like to create images that already contain test data to a certain extend.
For some services we rely on public docker images, that define volumes where data is stored.
I've observed, that docker does not persist data that is stored in these volume mounts (defined by the base image) during build. There are also questions around this issue like this, this or this issue.
Now given that it's the way how docker works, I wonder what would be a good approach to work around this issue?
This question here describes, how I could pre-populate a volume with data from the image - which is kind of the opposite of what I'd like to achieve.
Currently I'm setting up the images and move the pre-populated data from the volume mount to another directory at the end of the build. And on container start I link every subfolder back into the volume mounts. But this is kind of ugly as I have to link every subfolder seperately, because the parent folder is the volume mount and can not be linked.
Are there better ways? Is there even an "official" docker way to achive this?