you can override this by setting an IP on the port exposed so thet a local only server is only accessable on 127.0.0.1
Also, if the Docker container only has to be accessed from another Docker container, you don’t need to expose a port at all. Docker containers can reach other Docker containers in the same compose stack by hostname.





I self-host my emails, but use an SMTP relay for sending. IMO, the interesting part of self hosting email is the storage. Outbound sending is more complex and there’s not as much benefit to self-hosting it.
I use Mailcow and have it configured to use a relay per domain. Email clients use the Mailcow server as their SMTP server, and Mailcow (well, Postfix) handles sending it to the appropriate relay.