Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

Optimize the problem that the dovecot container has PID file that causes it to fail to start

aapanel.com73381b5aa497
diff --git a/Dockerfiles/dovecot/dovecot.sh b/Dockerfiles/dovecot/dovecot.sh
index 140400ab..68afeb38 100644
--- a/Dockerfiles/dovecot/dovecot.sh
+++ b/Dockerfiles/dovecot/dovecot.sh
@@ -1,6 +1,7 @@
#!/bin/bash
-useradd -r -u 150 -g mail -d /var/vmail -s /sbin/nologin -c "Virtual Mail User" vmail
+
+id vmail || useradd -r -u 150 -g mail -d /var/vmail -s /sbin/nologin -c "Virtual Mail User" vmail
chown -R vmail:mail /var/vmail
if [ ! -f "/etc/ssl/mail/dh.pem" ] || [ ! -f "/etc/ssl/mail/cert.pem" ] || [ ! -f "/etc/ssl/mail/key.pem" ]; then
diff --git a/Dockerfiles/dovecot/supervisord.conf b/Dockerfiles/dovecot/supervisord.conf
index b85b2105..1c377cc8 100644
--- a/Dockerfiles/dovecot/supervisord.conf
+++ b/Dockerfiles/dovecot/supervisord.conf
@@ -15,7 +15,7 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:dovecot]
-command=//usr/sbin/dovecot -F
+command=sh -c "rm -f /run/dovecot/master.pid && exec /usr/sbin/dovecot -F"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
@@ -23,6 +23,8 @@ stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
startsecs=10
+stopasgroup=true
+killasgroup=true
[eventlistener:processes]
command=/stop-supervisor.sh