It's an interesting point..
As a deciple of the BoFH philosophy, I can't believe I'm about to admit to knowing this, it makes me physically queesy:
This only happens if you actually forward the database port... If both DB and Frontend are containerised, then there is zero need to do that..
So it's not a fault of docker, more a poorly configured container...