Giter VIP home page Giter VIP logo

postfix-docker's Introduction

postfix-docker

Git repo for automated build of a postfix based docker container ready for OpenShift v3 (OSEv3)

This repository is used for sharing the work I've done for creating a postfix mailserver container. I've made this container keeping in mind the basic requirements for running this container in any containers' management system.

Environment variables

The docker container expects only one single env variable:
myhostname (string) the Hostname on which postfix is exposed. It's very important you set the current (external) hostname of the postfix server, for avoiding blacklist of some mail providers!

TL;DR Description

I've successfully tested the container in various OpenShift environments, mainly as SMTP server (or with proper customization to the config file, as SMTP Relay server).

The most challenging part was to correctly place the logs for sent emails (by postfix) directly on STDOUT. Logging to STDOUT ensures that some logs grabber (Fluentd in OpenShift v3) could take these logs and send them to the default logs management system (EFK - Elasticsearch/Fluentd/Kibana on OSEv3).

Unfortunately postfix by default wants to send logs to some rsyslog, that usually saves them to a log file, so I've been forced to create postfix container using multiple processes, violating what should be the best practice for creating a container: 1 process per container.

The three processes involved in the container creation were:

  • Postfix
  • Rsyslog
  • tail -f (on /var/log/maillog)

The last process to run and to leave in foreground, it was (for sure) the tail one. tail process will keep running in foreground while postfix and rsyslog do their job, but, what happen if postfix or rsyslog exits unexpectedly?
Nothing!
Docker container will keep running as soon as the tail process does. So your container orchestrator will never notice the absence of postfix process (unless you have some custom health check).

The solution I found was to use an internal processes orchestrator: supervisord (available in EPEL repo). Supervisord will be responsible to watch and keep them running your configured processes. If a process exits unexpectedly it will run the process again.
So your Docker's CMD/ENTRYPOINT will be the supervisord command.

Looking at 'resources' folder, you'll find the config file for rsyslog and supervisord, all the conf for postfix are done in place directly on Dockerfile.
Please note: as I said before, the container is pre-configured as a standard SMTP server, if you need some other configuration (for example: auth, relay, etc.) you should make the changes by yourself editing the Dockerfile.

As you can see in the root directory you'll find also the rhel7 version of the Dockerfile. Please keep in mind that for producing a working postfix container based on Red Hat Enterprise Linux 7 you should run the 'docker build' command on a RHEL7 machine.


Cheers.

References

The automated Docker build is here: https://hub.docker.com/r/alezzandro/postfix/ This container is also used in a Gitlab template, useful to create a persisten Gitlab on OSEv3 platform. More info at: https://github.com/sdellang/gitlab-openshift-persistent

postfix-docker's People

Contributors

alezzandro avatar

Watchers

James Cloos avatar Jeremy "Jay" Zahner avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.