Git Product home page Git Product logo

docker-iredmail's Introduction

docker-iredmail

This is an all-in-one container for iRedMail with OpenLDAP backend. It uses Phusion's baseimage-docker to make sure all processes shut down correctly.

Backups are disabled, because I snapshot my Docker volumes with ZFS regularily. To reenable them, just comment out one line from the Dockerfile.

If you like or use this project, please star it โ˜… on Github and Docker Hub.

Usage

Replace {variables} properly.

  1. Generate your iRedMail config file using the configure script. Amend passwords as you wish afterwards. If you are updating your container, read "Upgrading your container to a new version of iRedMail" below first.

  2. Build your image with docker build -t iredmail:0.9.6-0 --build-arg DOMAIN={first domain} build/. Note that this step will take some time.

  3. Create an intermediate container with docker create --name=iredmail iredmail:0.9.6-0.

  4. Extract some folders from the intermediate container and fix the owners:

    docker cp iredmail:/var/lib/ldap/{dn2dnsname} slapd-data
    docker cp iredmail:/var/vmail/vmail1 mails
    docker cp iredmail:/var/lib/dkim mail-domain-keys
    docker cp iredmail:/var/lib/mysql mail-mysql-data
    docker cp iredmail:/var/lib/clamav mail-clamav-data
    chown -R 107:111 slapd-data
    chown -R 2000:2000 mails
    chown -R 110:115 mail-domain-keys
    chown -R 105:109 mail-mysql-data
    chown -R 109:114 mail-clamav-data
    
  5. Remove the intermediate container with docker rm iredadmin.

  6. Start your permanent container with volumes properly attached. You will need a couple of docker arguments. Here's an example docker-compose file:

    mail:
      image: iredmail
      hostname: mail
      domainname: {first domain}
      ports:
        - "25:25"
        - "587:587"
        - "993:993"
      volumes:
        - /path/to/slapd-data:/var/lib/ldap/{dn2dnsname}
        - /path/to/mails:/var/vmail/vmail1
        - /path/to/mail-domain-keys:/var/lib/dkim
        - /path/to/mail-mysql-data:/var/lib/mysql
        - /path/to/mail-clamav-data:/var/lib/clamav
        - /path/to/ssl.key:/etc/ssl/private/iRedMail.key:ro # user: root, group: root, rights: 644
        - /path/to/ssl.crt:/etc/ssl/certs/iRedMail.crt:ro # user: root, group: root, rights: 644
      cap_add:
        - SYS_PTRACE # for UWSGI-iRedAdmin runsv script
        - NET_ADMIN
    
  7. Save your configuration file build/config in a save place. You will urgently need it if you are upgrading your container to a new version of iRedMail in future.

Upgrading your container to a new version of iRedMail

The configuration variables may change from release to release, so you have to recreate this file using the configure script if you are updating to a new version of iRedMail. You pick dummy values for all passwords.

Afterwards, compare it to your former config file and copy all passwords from the old to the new config file. Your LDAP_SUFFIX should not have changed, too - check the dn2dnsname you have provided if this is the case.

Using this updated config file, build your updated iRedMail container (see "Usage" above from step 2 on).

If you have lost the config file, you can restore all passwords manually from /opt/iRedMail.tips within your current container.

Upgrade notices

If you're uncertain, do not skip releases and only update from one release to the release immediately following it.

0.9.5(-1) -> 0.9.6

Restart your iRedMail container using the new iredmail:0.9.6 image.

iRedAPD

Execute the following SQL in iredapd's MySQL database:

CREATE INDEX client_address_passed ON greylisting_tracking (client_address, passed);

0.9.4 -> 0.9.5(-1)

First, shutdown your running iRedMail container.

MySQL

MySQL has been updated from 5.5 to 5.7, so we need to run the mysql_upgrade command twice. Please set your path accordingly.

docker run -it --rm -v /path/to/mail-mysql-data:/var/lib/mysql mysql:5.6 bash`

Inside the container, run:

chown -R mysql:mysql /var/lib/mysql
mysqld_safe &
mysql_upgrade -u root -p
mysqladmin -u root -p shutdown

Afterwards, repeat the same steps with mysql:5.7.

Slapd

Slapd database backend has changed from hdb to mdb, so we need to export and import again our data. Please set your {dn2dnsname} and paths accordingly.

docker run -i --rm -v /path/to/slapd-data:/var/lib/ldap/{dn2dnsname} iredmail:0.9.4-2 slapcat -f /etc/ldap/slapd.conf > ldap_export.ldif
docker run -i --rm -v /path/to/slapd-data-new:/var/lib/ldap/{dn2dnsname} iredmail:0.9.5-1 slapadd -f /etc/ldap/slapd.conf < ldap_export.ldif

Now, restart your iRedMail container using the new iredmail:0.9.5-1 image.

Roundcube

Within the recreated container, changedir into /opt/www/roundcubemail and run bin/update.sh.

Contribution

Pull requests very welcome! :-)

docker-iredmail's People

Contributors

kajoik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

docker-iredmail's Issues

Build failure due to missing tmp config file

Attempting to build the initial image and getting hung up on this particular issue.

Step 16/38 : COPY ./config ./ COPY failed: stat /var/lib/docker/tmp/docker-builder611491215/config: no such file or directory

Working inside an Ubuntu 18.04 LTS VM in Virtualbox.
Any insight would be greatly appreciated.

iRedMail 0.9.4 doesn`t support Ubuntu 16.04 (current phusion/baseimage)

$ docker build -t iredmail:0.9.4 --build-arg DOMAIN={first domain} build/
...
E: Unable to locate package php5-imap
E: Unable to locate package php5-json                                                                                                                                     
E: Package 'php5-gd' has no installation candidate                                                                                                                        
E: Package 'php5-mcrypt' has no installation candidate                                                                                                                    
E: Unable to locate package php5-curl                                                                                                                                     
E: Package 'php-apc' has no installation candidate                                                                                                                        
E: Unable to locate package php5-intl                                                                                                                                     
E: Unable to locate package php5-ldap                                                                                                                                     
E: Package 'php5-mysql' has no installation candidate                                                                                                                     
E: Package 'php5-fpm' has no installation candidate                                                                                                                       
E: Unable to locate package php5-intl                                                                                                                                     
<< ERROR >> Installation failed, please check the terminal output.
<< ERROR >> If you're not sure what the problem is, try to get help in iRedMail
<< ERROR >> forum: http://www.iredmail.org/forum/
nginx: unrecognized service
clamav-freshclam: unrecognized service                                                                                                                                    
clamav-daemon: unrecognized service                                                                                                                                       
amavis: unrecognized service                                                                                                                                              
php5-fpm: unrecognized service                                                                                                                                            
mysql: unrecognized service 
...

iRedMail 0.9.4 doesn`t support updated Ubuntu 16.04.
So, it needs to update ENV IREDMAIL_VERSION 0.9.5 in Dockerfile. I will create pull request

Fix error running shared postrotate script

/etc/cron.daily/logrotate:
Stopping iredapd ...
error: error running shared postrotate script for '/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
'
run-parts: /etc/cron.daily/logrotate exited with return code 1
/etc/cron.daily/spamassassin:
invoke-rc.d: policy-rc.d denied execution of reload.
Nov  9 06:54:21.579 mail3.velalu.qa /usr/sbin/amavisd-new[4241]: dkim: wildcard in signing domain (key#1, *), may produce unverifiable signatures with no published public key, avoid!

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.