For testing purposes I want to build a MySQL container that has a dataset bootstrapped into it. I know that mounting is possible and that you can place sql scripts into the init directory to run the import at start, but thats not what we want. So I tried to build one myself that just copies the datafiles into the docker container.
I use the following dockerfile to build my container.
FROM mysql:8.0.21
EXPOSE 3306
ARG BUILD_ID
LABEL stage=builder
LABEL build=$BUILD_ID
ENV TZ=Europe/Amsterdam
RUN apt-get update && apt-get install -y tzdata
ADD http://server.example.com/data/datafiles_2020_11_02.tar.gz /var/lib/datafile.tar.gz
RUN tar -xvzf /var/lib/datafile.tar.gz -C /var/lib/mysql && chown -R mysql.root /var/lib/mysql
#ADD initieel/* /docker-entrypoint-initdb.d/
ADD cnf/* /etc/mysql/mysql.conf.d/
This runs succesfully so afterwards I spin up my freshly build container and during the startup something in the container will just initialize a fresh database and throw everything that I placed into /var/lib/mysql away. I checked the README that comes with the mysql container but there is nothing I can find that relates to this.
thanks in advance for taking the time to read. I will update if my post is lacking any information.