I ended up running into this same issue. For anyone who faces this, you need to give execution permission to your script file, since Docker copies over permissions:
chmod +x your/script.sh
In my case the issue msg was:
/opt/bitnami/scripts/libpostgresql.sh: /docker-entrypoint-initdb.d/my-initdb.sh: /bin/bash: bad interpreter: Permission denied
Then I gave execution permission to my-initdb.sh
and it worked nicely