Sign inSign up

eyecreate/docker-mail

By eyecreate

Updated about 9 years ago

Image
0

1.1K

eyecreate/docker-mail repository overview

Docker-mail Docker registry MIT

A Dockerfile that runs a secure, configurable mailserver with all kinds of good stuff:

Howto

Build the docker image by running make or executing:

docker build [--rm] -t <user>/mail .
Configuration

In order to have all of the above mentioned features fully functional for your domain, and the email-addresses and aliases it hosts, run through each of the following steps. At the end you should have a <settings_folder> with a structured that is similar to the one in this repository that acts as an example.

  1. Create 2 persistent folders: one to hold the configuration/settings files and one that will act as mail storage.

    This can be on the server, and the folder names can be freely chosen. example:

     /opt/dockxs/mail/settings/
     /opt/dockxs/mail/data/
    

    Alternatively, those folders can be inside a data container, but with specific volumes.

    docker run -d --name mail-data \
               -v /settings \
               -v /data \
               busybox
    
  2. Add the FQDN of your server to the first line of the file <settings_folder>/hostname. Example:

     mydomain.net
    
  3. Add all the domains you want this server to receive mail for to the file <settings_folder>/domains in the following format:

     mydomain.net
     myotherdomain.org
    
  4. Add addresses and aliases you want to receive mail for to the file <settings_folder>/aliases in the following format:

    IMAP accounts will be created for each unique entry in the right column. Mails sent to the email addresses in the left column will be delivered in the corresponding IMAP account to the right.

  5. Add user passwords to the <settings_folder>/passwords in the following format:

     [email protected]:{SHA256-CRYPT}$6$e.n6OiX.c12RK2bz$zHHuDpq.Ewk0DXKYC.PDdjAb0jeaJM.zGm3K.hfqPDg/l.
     [email protected]:{PLAIN}pass12345
    

    In order to generate the hash values, you need to call doveadm pw -s <pw-scheme>. For this you need dovecot installed; this can be done locally, or by firing up this container in attached state by calling docker run -it --rm <user>/mail bash and then running mail-configure && doveadm pw -s <pw-scheme>. It's recommended to use SHA512-CRYPT as pw scheme.

  6. Generate the DKIM key (again, either you have opendkim installed locally, or you run this container in attached mode) by calling:

    opendkim-genkey -s mail -d mydomain.net
    

    This will create 2 files: (1) copy the mail.private file to the <settings_folder> and (2) the content of mail.txt needs to be set as the value of a TXT DNS Record for the key mail._domainkey.mydomain.net. (trailing dot!)

  7. Set up SPF, by adding "v=spf1 mx -all" as a TXT DNS Record for the key @

  8. Set up the Reverse PTR

  9. (Optional) Add your domain ssl private key and certificate to the <settings_folder>/ssl folder, so its content looks like:

     wildcard_private.key
     wildcard_public_cert.crt
    
Running the container

Once the container is build (or pulled from the hub), the folders for the settings and mail storage exist, and the configuration files are in place in the settings folder, you can run the container as follows:

  1. If the folders are on the server

    docker run -d [--name <name>] \
               -v <settings_folder>:/settings \
               -v <data_folder>:/data \
               -p 25:25 \
               -p 143:143 \
               -p 587:587 \
               -p 993:993 \
               <user>/mail
    
  2. If the folders are within a data container

    docker run -d [--name <name>] \
               --volumes-from mail-data \
               -p 25:25 \
               -p 143:143 \
               -p 587:587 \
               -p 993:993 \
               <user>/mail
    
  3. (Or mixed) with the settings folder on the server and the storage in a data container

    docker run -d --name mail-data \
               -v /data \
               busybox
    
    docker run -d [--name <name>] \
               -v <settings_folder>:/settings \
               --volumes-from mail-data \
               -p 25:25 \
               -p 143:143 \
               -p 587:587 \
               -p 993:993 \
               <user>/mail
    

License

Licensed under the MIT License. See the LICENSE file for details.

Feedback, bug-reports, requests, ...

Are welcome!

Tag summary

Content type

Image

Digest

sha256:b3fa4408e

Size

97.3 MB

Last updated

about 9 years ago

docker pull eyecreate/docker-mail