DB Initialization from volume?

I see that I can initialize a DB by putting a SQL file in /docker-entrypoint-initdb.d, but I think that means I have to mount a volume there . . . I think an easier way is to have an initContainer put the SQL file on the same volume as the DB, but that requires changing docker-entrypoint.sh to allow for $DATADIR/mysql/some-directory as a dir for SQL files, which requires creating a new, custom, container . . . does this sound like a bad idea? Is there better way? Thanks!!

Is my question not clear :frowning: ?

1 Like

Yes, maybe you should give more context and describe what your goal is and what you are doing.

Thanks! I would like to initialize a DB on startup of the container . . . I think that functionality already exists, and one can put a sql file in /docker-entrypoint-initdb.d on the container and it will get imported into the DB.

Getting the SQL file in /docker-entrypoint-initdb.d is a bit of a pain for me, though. I would prefer if docker-entrypoint.sh looked for the SQL init file on my PersistentVolume, where my database files will reside.

I have submitted this PR Added an ENV var to be set to an additional - optional - directory fo… by guymatz · Pull Request #625 · percona/percona-docker · GitHub

Is this an anti-pattern? Am I thinking about this the wrong way? Thanks again!!

1 Like