MySQL with Docker

I pulled  MySQL from https://hub.docker.com/_/mysql/.  This container doesn't work the way I expected, each time it is docker run it re-initialises by running docker-entrypoint.sh.  This script rebulds the DB.  

According to the information on hub.docker/_/mysql I can get the container to run special scripts etc, see point below

Initializing a fresh instance (docker run)

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. Files will be executed in alphabetical order. You can easily populate your mysql services by mounting a SQL dump into that directory and provide custom images with contributed data. SQL files will be imported by default to the database specified by the MYSQL_DATABASE variable.

Conclusion

I need to decide if I stick with the above image, look for a new image, or build one from scratch.  Time is now the issue.

info

I have decided to stick with th MySQL image from docker hub. There are clear instructions on how to setup root password. Once set I will use shell scripts to create other passwords for the man container. I will create a batch file for the grads to allow them to run the mysql image and pass a root password

Command to run

docker run -p 3307:3306 --name mysql-populated -e MYSQL_ROOT_PASSWORD=ppp -d mysql-db-populated:latest

parametermeaning
-p 3307:3306bind the container port 3306 to host port 3307
--name mysql-populatedthe runtime name of the container, can be used instead of image id
-ean environment variable to be passed into the container
mysql-db-populated:latestthe actual image name, can be found using docker images

The above command will run the mysql docker container and do a fresh init of the tables and lock down the db.  All tables are blank and there is no schema, so I need mysql to a script file rebuild the db, schema and populate the tables with data.  To do this, I have copied the schema from the working mysql container that I populated with data to my host.  I can the run this script from the command line.