Search code examples
sqldatabasedockercontainersdockerhub

Docker container with SQL database filled with records


Is there available SQL (MySQL/PostgreSQL/SQL Server etc.) Docker container with records?

I know there are SQL containers on docker hub, but those are "empty" databases. I'm looking for a container where already installed schemas, tables etc and those tables are filled with records.


Solution

  • You can see example of doing this for Postgres in https://github.com/Tornike-Skhulukhia/postgres-to-mongo-importer/blob/main/docker-compose.yml.

    Important part here is /docker-entrypoint-initdb.d/ , where you can put .sql files and when container starts it will execute the sql code in them.

    For more info on this feature look at "Initialization scripts" part here https://hub.docker.com/_/postgres