Docker-mailserver: Error: Please fix your configuration. Exiting...

Created on 24 Dec 2016  路  25Comments  路  Source: tomav/docker-mailserver

Hi guys,

I just pulled and updated image tvial/docker-mailserver:v2 and started seeing this in the logs:

mail_1               | 
mail_1               | #
mail_1               | #
mail_1               | # docker-mailserver
mail_1               | #
mail_1               | #
mail_1               | 
mail_1               | Initializing setup
mail_1               | Checking configuration
mail_1               | Configuring mail server
mail_1               | Error: Please fix your configuration. Exiting...
myapp_mail_1 exited with code 1

I'm using docker-compose.yml. Nothing has been changed in the config since the last docker-compose up around a month ago; all was working perfectly in the time-being.

Given that the image was updated just three hours ago, can it be some newly introduced bug or a backwards-compatibility issue? Others may struggle with the same thing as me I guess.

bug

Most helpful comment

So, sorry for the confusion.

With this docker-compose.yml file

version: '2'

services:
  mail:
    image: tvial/docker-mailserver
    # build: .
    hostname: mail
    domainname: xxx.xx
    ports:
      - "25:25"
      - "143:143"
      - "587:587"
      - "993:993"
      - "4190:4190"
    volumes:
      - /var/vmail/:/var/mail/
      - ./config/:/tmp/docker-mailserver/
      - ./letsencrypt/:/etc/letsencrypt/:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
     - ENABLE_FAIL2BAN=1
     - ENABLE_MANAGESIEVE=1
     - SSL_TYPE=letsencrypt
    # - DMS_DEBUG=1
    cap_add:
     - NET_ADMIN

I get:

Recreating mailserver_mail_1
Attaching to mailserver_mail_1
mail_1  |
mail_1  | #
mail_1  | #
mail_1  | # docker-mailserver
mail_1  | #
mail_1  | #
mail_1  |
mail_1  | Initializing setup
mail_1  | Checking configuration
mail_1  | Configuring mail server
mail_1  |   * Spamassassin is disabled. You can enable it with 'ENABLE_SPAMASSASSIN=1'
mail_1  |   * Clamav is disabled. You can enable it with 'ENABLE_CLAMAV=1'
mail_1  | Error: Please fix your configuration. Exiting...
mailserver_mail_1 exited with code 1

When enabling DMS_DEBUG=1 I get:

Recreating mailserver_mail_1
Attaching to mailserver_mail_1
mail_1  |
mail_1  | #
mail_1  | #
mail_1  | # ENV
mail_1  | #
mail_1  | #
mail_1  |
mail_1  | HOSTNAME=mail
mail_1  | ENABLE_MANAGESIEVE=1
mail_1  | DMS_DEBUG=1
mail_1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
mail_1  | ENABLE_FAIL2BAN=1
mail_1  | PWD=/
mail_1  | SHLVL=1
mail_1  | HOME=/root
mail_1  | SSL_TYPE=letsencrypt
mail_1  | _=/usr/bin/printenv
mail_1  |
mail_1  | #
mail_1  | #
mail_1  | # docker-mailserver
mail_1  | #
mail_1  | #
mail_1  |
mail_1  | Initializing setup
mail_1  |   Registering check,setup,fix,misc and start-daemons functions
mail_1  |   * _check_environment_variables() registered
mail_1  |   * _check_hostname() registered
mail_1  |   * _setup_default_vars() registered
mail_1  |   * _setup_dovecot() registered
mail_1  |   * _setup_dovecot_local_user() registered
mail_1  |   * _setup_dkim() registered
mail_1  |   * _setup_ssl() registered
mail_1  |   * _setup_docker_permit() registered
mail_1  |   * _setup_mailname() registered
mail_1  |   * _setup_postfix_override_configuration() registered
mail_1  |   * _setup_postfix_sasl_password() registered
mail_1  |   * _setup_security_stack() registered
mail_1  |   * _setup_postfix_aliases() registered
mail_1  |   * _setup_postfix_vhost() registered
mail_1  |   * _fix_var_mail_permissions() registered
mail_1  |   * _misc_save_states() registered
mail_1  |   * _start_daemons_cron() registered
mail_1  |   * _start_daemons_rsyslog() registered
mail_1  |   * _start_daemons_dovecot() registered
mail_1  |   * _start_daemons_opendkim() registered
mail_1  |   * _start_daemons_opendmarc() registered
mail_1  |   * _start_daemons_postfix() registered
mail_1  |   * _start_daemons_fail2ban() registered
mail_1  |   * _start_daemons_amavis() registered
mail_1  | Checking configuration
mail_1  |   Check that there are no conflicts with env variables [_check_environment_variables]
mail_1  |   Check that hostname/domainname is provided (no default docker hostname) [_check_hostname]
mail_1  |   * Hostname has been set to mail.xxx.xx
mail_1  | Configuring mail server
mail_1  |   Setting up default variables [_setup_default_vars]
mail_1  |   * Set ENABLE_LDAP=0
mail_1  |   * Set ENABLE_FETCHMAIL=0
mail_1  |   * Set ENABLE_MANAGESIEVE=1
mail_1  |   * Set DMS_DEBUG=1
mail_1  |   * Set VIRUSMAILS_DELETE_DELAY=7
mail_1  |   * Set ENABLE_POP3=0
mail_1  |   * Set ENABLE_SASLAUTHD=0
mail_1  |   * Set ENABLE_CLAMAV=0
mail_1  |   * Set SMTP_ONLY=0
mail_1  |   * Set ENABLE_FAIL2BAN=1
mail_1  |   * Set ENABLE_SPAMASSASSIN=0
mail_1  |   Setting up Dovecot
mail_1  |   * Sieve management enabled
mail_1  |   Setting up Dovecot Local User
mail_1  |   * Checking file line endings
mail_1  |   * Regenerating postfix user list
mail_1  |   * user 'everything' for domain 'xxx.xx' with password '********'
mail_1  |   * user 'support' for domain 'xxx.xx' with password '********'
mail_1  |   * user 'yyy' for domain 'xxx.xx' with password '********'
mail_1  |   Setting up DKIM
mail_1  |   * DKIM keys added for: xxx.xx
mail_1  |   * Changing permissions on /etc/opendkim
mail_1  |   Setting up SSL
mail_1  |   * Adding mail.xxx.xx SSL certificate
mail_1  |   * SSL configured with 'letsencrypt' certificates
mail_1  |   Setting up PERMIT_DOCKER Option
mail_1  |   * Adding container ip in my networks
mail_1  |   Setting up Mailname
mail_1  |   * Creating /etc/mailname
mail_1  |   Setting up Postfix Override configuration
mail_1  |   * No extra postfix settings loaded because optional '/tmp/docker-mailserver/postfix-main.cf' not provided.
mail_1  |   Setting up Postfix SASL Password
mail_1  |   * Warning: 'SASL_PASSWD' is not provided. /etc/postfix/sasl_passwd not created.
mail_1  |   Setting up Security Stack
mail_1  |   * Spamassassin is disabled. You can enable it with 'ENABLE_SPAMASSASSIN=1'
mail_1  |   * Clamav is disabled. You can enable it with 'ENABLE_CLAMAV=1'
mail_1  |   * Fail2ban enabled
mail_1  |   Setting up Postfix Aliases
mail_1  |   * Warning 'config/postfix-virtual.cf' is not provided. No mail alias/forward created.
mail_1  |   * Adding regexp alias file postfix-regexp.cf
mail_1  |   Setting up Postfix vhost
mail_1  |   Fixing /var/mail permissions
mail_1  |   * Permissions in /var/mail look OK
mail_1  | Starting Misc
mail_1  | Starting mail server
mail_1  |   Starting cron  [ OK ]
mail_1  |   Starting rsyslog  [ OK ]
mail_1  |   Starting dovecot services  [ OK ]
mail_1  |   Starting opendkim  [ OK ]
mail_1  |   Starting opendmarc  [ OK ]
mail_1  |   Starting postfix  [ OK ]
mail_1  |   Starting fail2ban  [ OK ]
mail_1  |   Starting amavis  [ OK ]
mail_1  |
mail_1  | #
mail_1  | # mail.xxx.xx is up and running
mail_1  | #

I just repulled the latest image with docker pull. docker-compose rm -v && docker-compose up doesn't help - same output as shown above.
Hope this helps in diagnosing the problem.

All 25 comments

Yes, it's possible, I worked late, tests were green but as you know, we don't have 100% coverage.
I introduced a DMS_DEBUG env. Set it to 1 to get full startup log and paste it here.
I'll add how to contribute (PR and issue) in #423

@kachkaev let me know if I can help.

Hi @tomav, thanks for this hint.

I tried adding DMS_DEBUG: 1 to my docker-compose.yml and the service has started! Interestingly enough, when I removed this environment variable and ran docker-compose down; docker-compose up, the container did not boot again. Tried this a few times just now. Any thoughts?

Could you paste your ENV via printenv?
I'll try to reproduce (after XMas sorry)

You mean printenv inside the container?

__UPD:__

root@gitlab:/services/gitlab/docker# docker exec -it gitlab_mail_1 bash
root@mail:/# printenv
HOSTNAME=mail
SASL_PASSWD=gitlab.kachkaev.ru ???:??? (replaced when pasting)
DISABLE_CLAMAV=1
DMS_DEBUG=1
VIRUSMAILS_DELETE_DELAY=7
LS_COLORS=
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PERMIT_DOCKER=network
PWD=/
DISABLE_SPAMASSASSIN=1
SHLVL=1
HOME=/root
SSL_TYPE=letsencrypt
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/printenv

I tried with your ENV and started well using DMS_DEBUG 1 or 0.
If your data persist outside the container, remove it and start again.

We know with @alinmear that a work needs to be done on function return value during startup.
If you have some time to dig into with us, feel free!

Could you paste startup log with and without debug?

Had the same problem on restart. Removing the container and restarting solved the issue.
However, there's something wrong that needs to be fixed.

A fast workaround would be to bypass the return values. So we would lose the possibility to check whether a configuration step was OK or not. It would be much better to identify the problem, which means on what step the error occurs.

Every configuration step is rather verbose, so post the section where the startup failed.

So we can see on what part the problem occurs, the return value!=0.

Yep, and I'll try to figure it out if I'm able to reproduce the problem on my dev environment.

@tomav, does this problem on restart only occurs with debug flag set to 1?

I had DMS_DEBUG=1 when I had the issue.
It was not the case for @kachkaev

So, sorry for the confusion.

With this docker-compose.yml file

version: '2'

services:
  mail:
    image: tvial/docker-mailserver
    # build: .
    hostname: mail
    domainname: xxx.xx
    ports:
      - "25:25"
      - "143:143"
      - "587:587"
      - "993:993"
      - "4190:4190"
    volumes:
      - /var/vmail/:/var/mail/
      - ./config/:/tmp/docker-mailserver/
      - ./letsencrypt/:/etc/letsencrypt/:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
     - ENABLE_FAIL2BAN=1
     - ENABLE_MANAGESIEVE=1
     - SSL_TYPE=letsencrypt
    # - DMS_DEBUG=1
    cap_add:
     - NET_ADMIN

I get:

Recreating mailserver_mail_1
Attaching to mailserver_mail_1
mail_1  |
mail_1  | #
mail_1  | #
mail_1  | # docker-mailserver
mail_1  | #
mail_1  | #
mail_1  |
mail_1  | Initializing setup
mail_1  | Checking configuration
mail_1  | Configuring mail server
mail_1  |   * Spamassassin is disabled. You can enable it with 'ENABLE_SPAMASSASSIN=1'
mail_1  |   * Clamav is disabled. You can enable it with 'ENABLE_CLAMAV=1'
mail_1  | Error: Please fix your configuration. Exiting...
mailserver_mail_1 exited with code 1

When enabling DMS_DEBUG=1 I get:

Recreating mailserver_mail_1
Attaching to mailserver_mail_1
mail_1  |
mail_1  | #
mail_1  | #
mail_1  | # ENV
mail_1  | #
mail_1  | #
mail_1  |
mail_1  | HOSTNAME=mail
mail_1  | ENABLE_MANAGESIEVE=1
mail_1  | DMS_DEBUG=1
mail_1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
mail_1  | ENABLE_FAIL2BAN=1
mail_1  | PWD=/
mail_1  | SHLVL=1
mail_1  | HOME=/root
mail_1  | SSL_TYPE=letsencrypt
mail_1  | _=/usr/bin/printenv
mail_1  |
mail_1  | #
mail_1  | #
mail_1  | # docker-mailserver
mail_1  | #
mail_1  | #
mail_1  |
mail_1  | Initializing setup
mail_1  |   Registering check,setup,fix,misc and start-daemons functions
mail_1  |   * _check_environment_variables() registered
mail_1  |   * _check_hostname() registered
mail_1  |   * _setup_default_vars() registered
mail_1  |   * _setup_dovecot() registered
mail_1  |   * _setup_dovecot_local_user() registered
mail_1  |   * _setup_dkim() registered
mail_1  |   * _setup_ssl() registered
mail_1  |   * _setup_docker_permit() registered
mail_1  |   * _setup_mailname() registered
mail_1  |   * _setup_postfix_override_configuration() registered
mail_1  |   * _setup_postfix_sasl_password() registered
mail_1  |   * _setup_security_stack() registered
mail_1  |   * _setup_postfix_aliases() registered
mail_1  |   * _setup_postfix_vhost() registered
mail_1  |   * _fix_var_mail_permissions() registered
mail_1  |   * _misc_save_states() registered
mail_1  |   * _start_daemons_cron() registered
mail_1  |   * _start_daemons_rsyslog() registered
mail_1  |   * _start_daemons_dovecot() registered
mail_1  |   * _start_daemons_opendkim() registered
mail_1  |   * _start_daemons_opendmarc() registered
mail_1  |   * _start_daemons_postfix() registered
mail_1  |   * _start_daemons_fail2ban() registered
mail_1  |   * _start_daemons_amavis() registered
mail_1  | Checking configuration
mail_1  |   Check that there are no conflicts with env variables [_check_environment_variables]
mail_1  |   Check that hostname/domainname is provided (no default docker hostname) [_check_hostname]
mail_1  |   * Hostname has been set to mail.xxx.xx
mail_1  | Configuring mail server
mail_1  |   Setting up default variables [_setup_default_vars]
mail_1  |   * Set ENABLE_LDAP=0
mail_1  |   * Set ENABLE_FETCHMAIL=0
mail_1  |   * Set ENABLE_MANAGESIEVE=1
mail_1  |   * Set DMS_DEBUG=1
mail_1  |   * Set VIRUSMAILS_DELETE_DELAY=7
mail_1  |   * Set ENABLE_POP3=0
mail_1  |   * Set ENABLE_SASLAUTHD=0
mail_1  |   * Set ENABLE_CLAMAV=0
mail_1  |   * Set SMTP_ONLY=0
mail_1  |   * Set ENABLE_FAIL2BAN=1
mail_1  |   * Set ENABLE_SPAMASSASSIN=0
mail_1  |   Setting up Dovecot
mail_1  |   * Sieve management enabled
mail_1  |   Setting up Dovecot Local User
mail_1  |   * Checking file line endings
mail_1  |   * Regenerating postfix user list
mail_1  |   * user 'everything' for domain 'xxx.xx' with password '********'
mail_1  |   * user 'support' for domain 'xxx.xx' with password '********'
mail_1  |   * user 'yyy' for domain 'xxx.xx' with password '********'
mail_1  |   Setting up DKIM
mail_1  |   * DKIM keys added for: xxx.xx
mail_1  |   * Changing permissions on /etc/opendkim
mail_1  |   Setting up SSL
mail_1  |   * Adding mail.xxx.xx SSL certificate
mail_1  |   * SSL configured with 'letsencrypt' certificates
mail_1  |   Setting up PERMIT_DOCKER Option
mail_1  |   * Adding container ip in my networks
mail_1  |   Setting up Mailname
mail_1  |   * Creating /etc/mailname
mail_1  |   Setting up Postfix Override configuration
mail_1  |   * No extra postfix settings loaded because optional '/tmp/docker-mailserver/postfix-main.cf' not provided.
mail_1  |   Setting up Postfix SASL Password
mail_1  |   * Warning: 'SASL_PASSWD' is not provided. /etc/postfix/sasl_passwd not created.
mail_1  |   Setting up Security Stack
mail_1  |   * Spamassassin is disabled. You can enable it with 'ENABLE_SPAMASSASSIN=1'
mail_1  |   * Clamav is disabled. You can enable it with 'ENABLE_CLAMAV=1'
mail_1  |   * Fail2ban enabled
mail_1  |   Setting up Postfix Aliases
mail_1  |   * Warning 'config/postfix-virtual.cf' is not provided. No mail alias/forward created.
mail_1  |   * Adding regexp alias file postfix-regexp.cf
mail_1  |   Setting up Postfix vhost
mail_1  |   Fixing /var/mail permissions
mail_1  |   * Permissions in /var/mail look OK
mail_1  | Starting Misc
mail_1  | Starting mail server
mail_1  |   Starting cron  [ OK ]
mail_1  |   Starting rsyslog  [ OK ]
mail_1  |   Starting dovecot services  [ OK ]
mail_1  |   Starting opendkim  [ OK ]
mail_1  |   Starting opendmarc  [ OK ]
mail_1  |   Starting postfix  [ OK ]
mail_1  |   Starting fail2ban  [ OK ]
mail_1  |   Starting amavis  [ OK ]
mail_1  |
mail_1  | #
mail_1  | # mail.xxx.xx is up and running
mail_1  | #

I just repulled the latest image with docker pull. docker-compose rm -v && docker-compose up doesn't help - same output as shown above.
Hope this helps in diagnosing the problem.

I'm seeing the same behavior as @ma-ver-ick

I got the same problem too and it seems like the problem come from volumes description in the docker-compose yaml.

I was using the same configuration than @ma-ver-ick and after multiple try, I found that using this

services:
  mail:
    image: tvial/docker-mailserver:2.1 
 [...]
    volumes:
    - maildata:/var/mail
    - mailstate:/var/mail-state
 [...]

 volumes:
  maildata:
    driver: local
  mailstate:
    driver: local

fix the configuration error.

Hope this helps

Hopefully today I have time to dig into this. Maybe this is connected to the the Misc function to save the container state.

So i found the problem:

it is linked with the DEBUG logic of @tomav for handling the verbosity of the container startup and the function _fix_var_mail_permissions.

the container starts up the first time as expected, because at first startup the first condition is met:

if [ find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | grep -c . != 0 ]; then
notify 'inf' "Fixing /var/mail permissions"
chown -R 5000:5000 /var/mail
else
notify 'inf' "Permissions in /var/mail look OK"
fi

the second time the first condition is false and the logic enters the else clause. We didn't enable the DEBUG FLAG, and so the notification msg is empty and the else clause would look like this:

[...]
else
[[ ! -z "${msg}" ]] && echo $options "${msg}"
[...]

So the else clause is empty which is not allowed in bash.

an easy and fast fix for this would be:

[...]
else
notify 'inf' "Permissions in /var/mail look OK"
return 0
[...]

see this gist for a simple and fast patchfile: https://gist.github.com/alinmear/9e887ef4913ce5646eb8b2bc3d3ee818

Hope this helps

@tomav you wrote

I had DMS_DEBUG=1 when I had the issue.
It was not the case for @kachkaev

Can you paste the output the container startup because then your problem can not be related with the problem of @kachkaev and @benne.

Thanks for spotting this. I'll PR your return 0 today except if you want to do it.
Regarding the problem, I was not able to reproduce it. I'll try again changing DMS_DEBUG value.

@tomav. it would be good for me, if you gonna make the PR! Thx so far!

@kachkaev image is building. Once done, could you pull and test it to see if it's better? Thank you.

Image ready.

Thanks for you work @tomav! I just commented-out DMS_DEBUG=1 and restarted the container, it worked! At least it gets to the point when I see:

mail_1               | 
mail_1               | #
mail_1               | # mail.example.com is up and running
mail_1               | #
mail_1               | 

The only thing that was not 100% obvious was that I had to change tvial/docker-mailserver:v2 to tvial/docker-mailserver:2.1 in my docker-compose.yml. Maybe updating two other tags (v2 and v2.1) on Docker Hub would be a useful thing for those who just want docker-compose pull && docker-compose up --force-recreate.

Feel free to close the issue; it looks solved to me!

Great.
I deleted v2.1 tag. A v note has been added to https://github.com/tomav/docker-mailserver/releases/tag/2.1 and documentation is up2date.

hi there
i have a TVS-671 Qnap installed mailserver docker image and everytime run it , this error message comes up ,.. i cant see this in settings on the menu , where do i go and what do i do please ?

Initializing setup
Checking configuration

  • Setting hostname/domainname is required
    Aborted
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rwarren picture rwarren  路  4Comments

Hamsterman picture Hamsterman  路  3Comments

ShuP1 picture ShuP1  路  4Comments

dragonito picture dragonito  路  5Comments

xiao1201 picture xiao1201  路  4Comments