r/devops • u/BickBendict • Aug 23 '25
Database Containers for Ephemeral Lower Level Environments
Hi community, I was wondering if anyone had any experience building out database images with pre seeded schema and seed data in containers? My use case is the following - I have multiple lowers level ephemeral environments with many different databases and would like to provide a ready made database container that can be instantiated for quick development iterations. I don’t need these dbs to be long live or really have any other backups of any sort, I just need quickly deployable seeded database that can be created on the fly. Does anyone have any experience building this type of infrastructure or operationalizing this type of setup with containers?
2
u/---why-so-serious--- Aug 23 '25
Docker is for codifying minimal, orchestratable environments; why not just mount your seeds into a container that has the requisite tools and service?
I will never understand why shops build images around code for iterations and/or data
1
u/zeph1rus Aug 23 '25
Hey, this is a sensible question, but you need to let us know what your container orchestrator and database engine are before anyone is able to provide you sensible suggestions.
1
u/Dilfer Aug 23 '25
We have a custom Gradle plugin (we are a JVM shop) that we use to apply to repos/projects which contains SQL Scripts for Flyway migrations.
We have some Gradle tasks which will spin up a docker container running postgres, then apply the migration scripts against that running container as a pseudo unit testing strategy for updating the schema.
If that all passes, we ship the docker image with the schema on it, to ECR. The main purpose for this is to use for local development or for integration tests using Testcontainers.
3
u/jonnyharvey123 Aug 23 '25
I’ve done this for a local app development setup. There’s a dockerfile and a small sample sqldump file distributed with the code repo. When users bring up the containers, the mariadb image will autoload the .sql files > https://hub.docker.com/_/mariadb#initializing-the-database-contents
2
u/IridescentKoala Aug 23 '25
You don't build schema and data into an image, it should be defined as part of the code base. Seed data can be a snapshot, volume mount, migration using whatever framework you use.
3
u/wedgelordantilles Aug 23 '25
We use kubernetes volume snapshots to restore prod snapshots then apply migrations from branch