DEV Community

Discussion on: Learn Docker — from the beginning, part V Docker Compose, variables, volumes, networks and databases

Collapse
 
opensas profile image
opensas

WOW! Excellent guide indeed.

I got a bit lost in the last step. What does the "ADD init.sql /docker-entrypoint-initdb.d" really do (just copying the file?) and how come mysql knows it has to run it? Or is it something programmed in the mysql:5.6 image? and how does it auths to the db?

The other question I wanted to ask, is how would you combine all this with a git repo in order to trigger automated tests and, if everything goes ok, automatic deploy?

Collapse
 
softchris profile image
Chris Noring Microsoft Azure

Thanks for that :)

From hub.docker.com/_/mysql
When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d

if I understand your question correctly that's a whole chapter in the official Docker documentation, docs.docker.com/docker-hub/builds/