Support init scripts for MongoDBContainer
without manually customizing the WaitStrategy
#3066
Open
Description
A container initialized as follows, fails to start:
MongoDBContainer c = new MongoDBContainer(MONGO_IMAGE)
.withEnv("MONGO_INITDB_ROOT_USERNAME", "root")
.withEnv("MONGO_INITDB_ROOT_PASSWORD", "password" )
.withFileSystemBind("init/mongo-init.js",
"/docker-entrypoint-initdb.d/mongo-init.js", BindMode.READ_ONLY)
;
c.start()
Not sure but probably because the docker-entrypoint.sh, in case of presence of init-db scripts, does a shutdown and a restart of the process after executing them:
if [ -n "$shouldPerformInitdb" ]; then
...
echo
for f in /docker-entrypoint-initdb.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.js) echo "$0: running $f"; "${mongo[@]}" "$MONGO_INITDB_DATABASE" "$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
done
"${mongodHackedArgs[@]}" --shutdown
rm -f "$pidfile"
...