bokysan / docker-postfix

Multi architecture simple SMTP server (postfix null relay) host for your Docker and Kubernetes containers. Based on Debian/Ubuntu/Alpine.
MIT License
555 stars 152 forks source link

[Feature] Set healthcheck port in configuration options #186

Closed undefinedid closed 1 month ago

undefinedid commented 9 months ago

I'm actually using your image in many different places and in many different ways, even in production in my workplace. I could hardly do without it! So thank you for maintaining it!

In my homelab, I use it as a local relay, non-authenticated. It uses port 25 to catch local emails, and relays them on the secure port 587 of a cloud provider.

My container constantly says it is unhealthy, because of my local port 587 is not open.

I think the source of this behavior is located here: healthcheck.sh#L10

Do you think it could be possible to pass healthcheck some options, via environment variables, in a future version? I'm mainly thinking of the listening port but it may be helpful to pass other settings.

Thank you for your work and for your help.

bokysan commented 9 months ago

Sure, that can be changed to use a variable. Although, usually you don't need to change the (internal) listening ports of services, as you can map them to your preferred ports on the outside in Docker as well as Kubernetes.

I'd be interested to understand why you have the need to change the listening port in the first place?

undefinedid commented 8 months ago

Thank you for your answer. I didn't touch anything regarding the port used by Postfix. Settings are those deployed by the image on the first launch. Even /etc/postfix/master.cf is untouched:

smtp      inet  n       -       n       -       -       smtpd

I think my docker-compose and my environment variables make the process bind the port 25 naturally, as their is no authentication and no SSL/TLS at all on the input.

And as in my previous experiences with baremetal installs or with other container images, it didn't trigger me as it is the expected behavior for clients or servers to use this port unauthenticated.

But as you mentioned it, I could map port 25 on the host to port 587 inside the Postfix container to make it status healthy. I'm just not very familiar when both input and output are on the same port, 587.