You have just described Testcontainers [1] , and if you are a Java developer you may want to look into Testcontainers for Java [2].
For example, in one of my projects I use TestNG to instantiate a MariaDB container, run the Flyway migrations on it and then populating the tables with the test data:
For example, in one of my projects I use TestNG to instantiate a MariaDB container, run the Flyway migrations on it and then populating the tables with the test data:
[1] https://testcontainers.com/ [2] https://java.testcontainers.org/