Deploying Mailcow: A Self-Hosted Mail Server In Docker

Setting up an efficient mail server is crucial for individuals and organizations. Mailcow, a comprehensive mail server solution, offers a user-friendly interface and a wide range of features. In this guide, I’ll walk you through the process of installing Mailcow on Debian Bookworm and Docker, ensuring a smooth and hassle-free experience.

If you want to discuss the topic with other technology-minded people, join my Discord: https://discord.gg/YbSYGsQYES

Now we have an IRC channel as well: irc.libera.chat / #tomsitcafe

Prerequisites

Before diving into the installation process, make sure you have a Debian Bookworm server ready with a clean installation. Additionally, ensure that you have root access or sudo privileges to execute commands.

Update and upgrade

Start by updating the package lists and upgrading existing packages on your Debian Bookworm server. This ensures that you have the latest software versions and security patches.

sudo apt update
sudo apt full-upgrade

Install docker and docker-compose

Mailcow relies on Docker and Docker Compose for containerization. Install these essential components by running the following commands:

sudo apt install docker.io docker-compose

Or follow the Docker installation guide.

Ensure that Docker is started and set to launch on boot:

sudo systemctl enable docker

Clone the mailcow repository

Clone the Mailcow repository from GitHub to your server as the root user.

git clone https://github.com/mailcow/mailcow-dockerized

Navigate to the newly created directory:

cd mailcow-dockerized

Initialize mailcow

Run the following command as root to initialize Mailcow and create the required Docker containers:

./generate_config.sh
docker compose up -d

Wait for the process to complete. This may take some time as Docker downloads and configures the necessary components. The script runs as root but it drops permissions for every exposed application and will not run an exposed service as root!

Access the mailcow web interface

Once the installation is complete, access the Mailcow web interface using your server’s IP address or domain name. Open your web browser and navigate to:

http://your_server_ip

Log in with the default credentials (admin as the username and moohoo as the password) and follow the on-screen instructions to configure your mail server settings.

Final thoughts

Congratulations! You have successfully installed Mailcow on Debian Bookworm, providing a reliable and feature-rich mail server solution. Feel free to explore the Mailcow documentation for additional customization options and advanced features.

If you want to discuss the topic with other technology-minded people, join my Discord: https://discord.gg/YbSYGsQYES

Leave a comment