Docker Community Forums

Share and learn in the Docker community.

How best to populate a MySQL database?



I have a MySQL database I’ve got running in a container as part of a docker-compose file with a REST service. What I’m wondering is how best to populate that database since it’s just an empty MySQL default instance.

Since I have a REST service running in another container, maybe populating the database programmatically from the service would be the best route?

Looking for suggestions from the community here. :slight_smile:

Thanks for any suggestions.

(Martin Terp) #2
      - ./dump.sql:/docker-entrypoint-initdb.d/dump.sql

The image runs every SQL file in that dir, at creation point :slight_smile:


Thank you very much. This worked perfectly. :slight_smile:

(Ove "Lime" Lindström) #4

A note: it is going to run it in alphanumeric order. I recommend that you prefix the sql files with a number, for example like this:

and so on.


Thanks for that information. I’ll do that.