I found out what happened. The database wasn’t shut down cleanly, probably because of the previous devicemapper setup. In this case the database definitely needs much longer than 5 seconds to start up.
Since an unclean shutdown can happen to anyone, I’ve submitted this:
https://github.com/discourse/discourse_docker/issues/309
I’m trying out to modify the sleep value.