Skip to content

Postfix server container with several features

License

forestsource/postfix

 
 

Repository files navigation

postfix

Postfix is a Mail Transport Agent (MTA).

How to build the container

docker build --tag=docker.io/modularitycontainers/postfix .

How to use the container over standard 25 port

Command for running postfix docker container:

docker run -it -e MYHOSTNAME=localhost \
    -p 25:10025\
    -v /var/spool/postfix:/var/spool/postfix \
    -v /var/spool/mail:/var/spool/mail postfix
    -d docker.io/modularitycontainers/postfix

How to use the container over standard TLS

Command for running postfix docker container:

docker run -it -e ENABLE_TLS -e DEBUG_MODE -e MYHOSTNAME=localhost \
    -p 25:10025 \
    postfix -d docker.io/modularitycontainers/postfix

Environment variable DEBUG_MODE is used for debugging purposes from postfix point of view.

How to use the container with IMAP.

Command for running postfix docker container:

POSTFIX_CERTS_PATH=/etc/postfix/certs
docker run -it -e ENABLE_IMAP -e MYHOSTNAME=localhost
    -e DEBUG_MODE \
    -p 587:10587 \
    -v ${POSTFIX_CERTS_PATH}:/etc/postfix/certs \
    postfix -d docker.io/modularitycontainers/postfix

POSTFIX_CERTS_PATH contains certificates used by postfix, like self signed certificate, keys, etc.

The example tree generated for localhost certificate can look like:

$ tree /etc/postfix/certs/
/etc/postfix/certs/
├── localhost.crt
├── localhost.csr
└── localhost.key

Environment variable DEBUG_MODE is used for debugging purposes from postfix.

How to generate self signed SSL certificate for postfix

In case, you enable TLS support for postfix, you need to have certificates for postfix service.

For more information about Postfix TLS support see http://www.postfix.org/TLS_README.html

The page POSTFIX_CERTS_GENERATION.md will help you with generation self signed certificate used by postfix.

S2I extensibility

You can configure this container to adhere your needs using Source-to-Image and shell scripts. To create a new Docker image named postfix-app, that will be configured by your needs, just setup this directory: ./app-name/postfix-pre-init that will contain *.sh scripts that will be executed right before postfix will start, so you can use postconf and other tools to configure postfix. Then just excute the s2i build:

s2i build file://path/to/app-name docker.io/modularitycontainers/postfix postfix-app

You can execute such image as you would non-s2i one:

docker run -it -e MYHOSTNAME=localhost \
    -p 25:10025\
    -v /var/spool/postfix:/var/spool/postfix \
    -v /var/spool/mail:/var/spool/mail \
    -d postfix-app

In this repo you can find an example for you to try this out. It implements an example of a null client configuration, as described here. All it does is display the configuration, change it according to example and display it again. Assuming your working directory is this repository, just run:

s2i build file://$(pwd)/example docker.io/modularitycontainers/postfix postfix-example

And then run it:

docker run -it \
    -p 25:10025\
    -v /var/spool/postfix:/var/spool/postfix \
    -v /var/spool/mail:/var/spool/mail \
    -d postfix-example

How to test the postfix mail server

See help/help.md file.

About

Postfix server container with several features

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 69.2%
  • Python 15.8%
  • Makefile 15.0%