Yes, that is true if you keep your passwords in the docket compose file.
It was more meant to illustrate the point how to externalise the settings.
The actual secret injection normally depends on the container orchestration mechanisms.
For docker swarm you can read more about it here: Manage sensitive data with Docker secrets | Docker Documentation, for Kubernetes it uses A similar approach: Secrets | Kubernetes, GCP and AWS ECS have their proprietary ways of injecting secrets from secure wallets.
One thing they all have in common: the never store the plain text secrets in the actual deployment descriptor files (like docker-compose.yml). But the mechanism for injection is oftentimes the system env vars.
Cheers
Mario