Greetings,
Having issues to start a container that build using Dockerfile.
I am trying to simply run a CentOS image that has Postfix configured with SendGrid or any SMTP Relay service # KB # Integrate SendGrid with Postfix - SendGrid Documentation | SendGrid | Twilio
Dockerfile below:
FROM centos:7
# Update package repository and install postfix and SASL
RUN yum update -y && yum install -y postfix cyrus-sasl-plain
# Configure postfix to listen on all interfaces and enable SASL
RUN sed -i 's/inet_interfaces = localhost/inet_interfaces = all/' /etc/postfix/main.cf \
&& echo "broken_sasl_auth_clients = yes" >> /etc/postfix/main.cf \
&& echo "smtpd_sasl_auth_enable = yes" >> /etc/postfix/main.cf \
&& echo "smtpd_sasl_security_options = noanonymous" >> /etc/postfix/main.cf \
&& echo "smtp_sasl_tls_security_options = noanonymous" >> /etc/postfix/main.cf \
&& echo "smtp_tls_security_level = encrypt" >> /etc/postfix/main.cf \
&& echo "header_size_limit = 4096000" >> /etc/postfix/main.cf \
&& echo "relayhost = [smtp.sendgrid.net]:587" >> /etc/postfix/main.cf
# Expose the SMTP port (25)
EXPOSE 25
# Run a script to create a SASL password file for the specified user with the specified password
CMD ["/bin/bash", "-c", "echo $USERNAME $PASSWORD > /etc/postfix/sasl_passwd && chmod 600 /etc/postfix/sasl_passwd && echo 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' >> /etc/postfix/main.cf && postfix start"]
Then I do a docker build
docker build -t user/centos-postfix-sendgrid . --no-cache=true --platform=linux/amd64
Then docker run
docker run -itd --cap-add=NET_BIND_SERVICE -p 2513:25 -e USERNAME=apikey -e PASSWORD=passwordhere --name centos7_postfix_sendgrid user/centos-postfix-sendgrid
The container doesnât start, not sure what issue is here. Any ideas?
Thanks