I have a minimal example mysql library.
seed.sql:
create schema MyDatabase;
use MyDatabase;
create table MyTable(MyNumber int);
insert into MyTable values (70);
Dockerfile:
FROM mysql
COPY *.sql /docker-entrypoint-initdb.d/
Part of my docker-compose.yml:
my-database:
build: my-database
environment:
- MYSQL_ROOT_PASSWORD
Now if I change 70
to 71
in insert into MyTable values (70);
and run docker compose up --build -d my-database
, I'd expect a new image to be created with the new seed file.
But instead, the old value of 70 is still in the database (I connect directly using mysql cli to check). I need to run docker compose rm my-database first for my seed.sql changes to take effect.
My question is why is that? Shouldn't changes to the seed.sql file cause docker to create a brand new image for my-database, which would force it to completely relaunch the service?
Another similar question - Scripts in the /docker-entrypoint-initdb.d folder are ignored