Docker Community Forums

Share and learn in the Docker community.

How do I initialize a mysql container with a mysql .sql script file or how to I add a database and save the image?


(Wexwuffley) #1

I am interested in saving an image file with MySQL running a database that I have defined in a MySQL .sql script file. How would I go about doing this please?

Thanks,

Wex


(Martin Terp) #2

Hi :slight_smile:

Take a look at this:

This will create a image from a running container.


(Jica) #3

You can create a new image FROM https://hub.docker.com/_/mariadb/ and COPY your .sql file to /dcoker-entrypoint-initidb.d/ :

FROM mariadb

COPY MySQL.sql /docker-entrypoint-initdb.d/