So in order to have a docker instance of a replica set MongoDB I need to modify the local etc/hosts file?
How has that behavior ever rolled to a production version?

What about environments I do not have access to the system configuration (eg. CI/CD pipelines)?