I am trying to build a new mysql image from an existing one, and then insert some records into the database as part of the build process to create the new image (i.e. new mysql image = old mysql image + extra table records).
I am not able to add an sql file that contains my insert queries to /docker-entrypoint-initdb.d, cause that is not executing the scripts inside that directory (because the starting image already has a /var/lib/mysql dir available?).
I have tried to do something like the following instead:
FROM my.registry/starting-mysql-img:latest
ADD insert-queries.sql /tmp
RUN mysql -u root mydb < /tmp/insert-queries.sql
But I get a
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error.
What am I doing wrong / is there an alternative way to achieve my I am looking for?