I am aware that Mailcow team doesn’t provide support and advise to use LXC container to run a mailcow dockerized version.
But accept community usage without support for them ! (mailcow/mailcow-dockerized#4215)
It’s important to have access to the hypervisor, so you can’t use LXC for VPS provider ! But your own server with LXC VMs on it.
But in some case (mine for example) is mandatory. The ressource of the hardware that going to run the VPS is not enought for a full KVM machine.
I finnaly manage to succesfully run mailcow January Update 2022 on in a unprivileged LXC container with Proxmox.
You may need to modify some configuration, the max number of process for dovecot docker for example.
I - Prepare your proxmox hypervisor
Loging into your proxmox hypervisor.
Need to load overlay and naufs module on proxmox :
echo -e “overlay\naufs” >> /etc/modules-load.d/modules.conf
Install cgroups-mount (don’t really knwon if finally need but it’s done in my case) :
apt-get install cgroups-mount
II - Prepare a unprivileged LXC container
I choose to use debian-11-standard_11.0-1_amd64 as CT template.
Make a new container, as usual via the proxmox GUI. My basic configuration was :
Loging into your VPS (LXC container just created).
Be sure to be with the last version of all your system :
Configure your timezone :
I choose to remove postfix and use msmtp (a smtp client) to manage local mail of the container.
For the cron task and other system app who want to send me a mail !
That’s going to let free the port 25 of the LXC container (localy).
apt-get purge postfix
apt-get install msmtp-mta (be carefull, use msmtp-mta, not only msmtp because msmtp-mta include a sendmail emulation)
Edit the config file,and paste the line below to it, of msmtp with :
I use gmail to manage system email, of course don’t use email for mailcow because if you have some issue on it, you will not
be advise by the system. I choose gmail by IMAP (by sure to enable less secure apps on Gmail for IMAP).
This is my config of msmtp (change USERNAME and PASSWORD) :
Now, we going to install a command line mail client :
apt-get install bsd-mailx
Edit your aliases files, with
This is my aliases file you need to personnalize with your mail :
And finally, secure a little bit your LXC container with a mail each time someone log to your system (My TIPS). Edit bash config :
And add this line at the end of the file :
echo ‘ALERT - Shell Access on: ’ `date` `who` | mail -s “Alert: Shell Access on `hostname -f`” root
If you log out, and loging again, you should receive a mail with this alert. Great, everything seems to work.
If not, take a look on /var/log/msmtp.log to debug.
OPTION (just for daily backup cronjob, see https://mailcow.github.io/mailcow-dockerized-docs/backup_restore/b_n_r-backup/) :
I choose to share my BACKUP storage of my proxmox (a external NAS) with my mailcow LXC container. This is the storage where I put of my VM backup with vzdump on Proxmox.
I will add a crontask to manage a daily backup of my data, so I have to make a local mount folder :
chmod 777 /mnt/NAS
The VPS is almost done now, stop with :
Now add this configuration in the proxmox LXC config, add the end of the file (/etc/pve/lxc/VMID.conf on a proxmox shell) :
#OPTION for daily cronjob, should be personnalize with your own storage
lxc.mount.entry: /mnt/pve/NAS mnt/NAS/ none rw,bind 0 0
You can now run again your VPS, we are ready to install mailcow !
III - Mailcow installation
Boot your VPS, and login into to again and follow the installation documentation : https://mailcow.github.io/mailcow-dockerized-docs/i_u_m/i_u_m_install/
At the step 5, don’t run “docker-compose up -d”, we going to modify some config before.
Edit /opt/mailcow-dockerized/docker-compose.yml with :
In redis-mailcow section, comment/remove thoses lines (https://community.mailcow.email/d/1054-sysctl-for-redis-breaks-on-lxclcd/2)
# - net.core.somaxconn=4096
For us, it’s totally useless, because on 5.4 kernel (it’s the case of proxmox 6.4-13 somaxconn is already 4096 but docker in LXC does’nt support this option).
Finally in dovecot-mailcow section, modify nproc limits
nproc: 30000 #(Instead of 65535)
Not a big deal on a home usage even for more, it’s limit the number of process inside the dovecot docker.
You should now run :
docker-compose up -d
Mailcow-dockerized version should run now just fine, you are ready to finalize your mailcow configuration !
Don’t forget, if you choose the option, to make the cronjob for daily bakcup (https://mailcow.github.io/mailcow-dockerized-docs/backup_restore/b_n_r-backup/)