Import dump SQL in mysql server

Hello !

I have a question about how to populate a database by using a SQL dump at the launch of a container.
I tried this but it does not work:

FROM mysql:5.6.24
EXPOSE 3306
ENV MYSQL_DATABASE=testlink
ENV MYSQL_ROOT_PASSWORD=kereval
ENV MYSQL_USER=kereval
ENV MYSQL_PASSWORD=kereval
VOLUME [“/var/lib/mysql”]
ADD 00-dump.sql /docker-entrypoint-initdb.d/00-dump.sql
ADD docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint-initdb.d/00-dump.sql
RUN ./docker-entrypoint.sh

Do you have any idea how to proceed ? Thank you !

What’s in the docker-entrypoint.sh script? This is probably the right path, except that you can’t RUN the script during the docker build phase, you need to run it as an ENTRYPOINT (and make sure to also run the base mysql container’s entrypoint script as well).

Speaking of the stock mysql image’s entrypoint script, you should read through https://github.com/docker-library/mysql/blob/master/5.6/docker-entrypoint.sh, which makes it sound like all you need to do is COPY the one file to /docker-entrypoint-initdb.d/; you don’t need to provide or replace your own entrypoint script.

Remember that these details are visible to anybody who runs docker history on your image, and baking passwords like this into an image is distinctly not a best practice.