1 (edited by sunyuchen2014 2023-12-12 14:32:30)

Topic: iRedMail docker container failed to run when want to persist logs

I am trying to run a dockerized iredmail server as shown by the dockerized repo on github. For debug purpose, I want to mount the logs generated by the program in container to our host. So when I user tells me a mail from A to B hasn't been received for a long time, I can quickly check what has happened.

After check, I found the logs are under /var/log, so I thought just simply mounted it to a volume on host. I start the container with the following command.

docker run -itd \
    --rm \
    --name iredmail \
    --env-file iredmail-docker.conf \
    --hostname mail.webmail.spinquanta.com \
    -p 80:80 \
    -p 443:443 \
    -p 110:110 \
    -p 995:995 \
    -p 143:143 \
    -p 993:993 \
    -p 25:25 \
    -p 465:465 \
    -p 587:587 \
    -v /home/spinq/iredmail-docker/data/backup-mysql:/var/vmail/backup/mysql \
    -v /home/spinq/iredmail-docker/data/mailboxes:/var/vmail/vmail1 \
    -v /home/spinq/iredmail-docker/data/mlmmj:/var/vmail/mlmmj \
    -v /home/spinq/iredmail-docker/data/mlmmj-archive:/var/vmail/mlmmj-archive \
    -v /home/spinq/iredmail-docker/data/imapsieve_copy:/var/vmail/imapsieve_copy \
    -v /home/spinq/iredmail-docker/data/custom:/opt/iredmail/custom \
    -v /home/spinq/iredmail-docker/data/ssl:/opt/iredmail/ssl \
    -v /home/spinq/iredmail-docker/data/mysql:/var/lib/mysql \
    -v /home/spinq/iredmail-docker/data/clamav:/var/lib/clamav \
    -v /home/spinq/iredmail-docker/data/sa_rules:/var/lib/spamassassin \
    -v /home/spinq/iredmail-docker/data/postfix_queue:/var/spool/postfix \
    -v /home/spinq/iredmail-docker/log:/var/log
    iredmail/mariadb:stable

When I added the -v /home/spinq/iredmail-docker/log:/var/log line it failed with the following error. If I didn't have that line, everything works fine.

2023-12-12 03:49:32,432 INFO spawned: 'fail2ban' with pid 2934
2023-12-12 03:49:32,442 INFO success: fail2ban entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2023-12-12 03:49:32,447 INFO exited: nginx (exit status 1; not expected)
2023-12-12 03:49:32,450 INFO spawned: 'nginx' with pid 2935
2023-12-12 03:49:32,456 INFO success: nginx entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2023-12-12 03:49:32,461 INFO exited: nginx (exit status 1; not expected)
2023-12-12 03:49:32,552 INFO spawned: 'nginx' with pid 2936
2023-12-12 03:49:32,553 INFO exited: fail2ban (exit status 255; not expected)

Can someone tell me why, and how should I collect logs properly?

Also, I do wants to customized the location of logs, at least give the mail.log a directory. Is there a way to implement this?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: iRedMail docker container failed to run when want to persist logs

File owner / group / permission issue of the mounted log directory?

3 (edited by sunyuchen2014 2023-12-26 17:10:39)

Re: iRedMail docker container failed to run when want to persist logs

ZhangHuangbin wrote:

File owner / group / permission issue of the mounted log directory?

Previous tests were done on a VM. Today I tried with a Ubuntu 22.04 cloud server again. I use a user named mila, and the mounted host directory is /home/mila/iredmail/data under my home directory, with both owner and group mila, and permission 777.

If I do not mount /var/log, the application works properly.

If I mount /var/log, the docker container keeps running (unlike when using a VM, the docker container fails down), but the webpages are not accessible. Nginx and fail2ban exit frequently with the same logs as I shown before.

Most of the log folders in /var/log has been mounted to the host directory, but some log files, for example the nginx log folder, is not created in this case. Such folders/files created when not mounted and not created when mounted /var/log includes:
alternatives.log   btmp   faillog   lastlog   private   uwsgi   apt   bootstrap.log   dpkg.log   fail2ban.log   journal   nginx   wtmp

Also, I notice the owners and groups of log files may not be mila, will that affect the execution result?

drwxrwxrwx 14 mila  mila   4.0K 12月 26 13:12 .
drwxrwxr-x  3 mila  mila   4.0K 12月 26 13:21 ..
drwxrwxrwx  2 mila  mila   4.0K 12月 26 11:43 backup-mysql
drwxr-xr-x  3 uuidd render 4.0K 12月 26 13:59 clamav
drwxrwxrwx 10 mila  mila   4.0K 12月 26 13:59 custom
drwxrwxrwx  2 mila  mila   4.0K 12月 26 13:51 imapsieve_copy
drwxrwxrwx  4 mila  mila   4.0K 12月 26 13:59 logs
drwx------  2  2000   2000 4.0K 12月 26 13:53 mailboxes
drwxrwxrwx  2  2003   2003 4.0K 12月 26 11:45 mlmmj
drwxrwxrwx  2  2003   2003 4.0K 12月 26 11:45 mlmmj-archive
drwxrwxrwx 11 mila  mila   4.0K 12月 26 13:59 mysql
drwxrwxrwx 17 mila  mila   4.0K 12月 26 13:26 postfix_queue
drwxrwxrwx  3 mila  mila   4.0K 12月 26 13:59 sa_rules
drwxrwxrwx  2 mila  mila   4.0K 12月 26 13:59 ssl

Still, is there some helpers used to manage logs? Logs of several different modules are collected to different locations, and rotated by different rules, and I feel its a little bit hard to manage them currently.