How to Install Monica Using Docker on Unraid

How to Install Monica Using Docker on Unraid
If you enjoy organizing your personal life using digital tools and prefer self-hosted solutions, you may have already heard of Monica. Monica is an open-source web application for managing personal relationships. Think of it as a CRM, but for your personal life. Today, I will guide you through the process of installing Monica using Docker on Unraid. I’ll also provide a detailed explanation of the YAML file used for Docker Compose.
Prerequisites
Before diving into the YAML file, let’s cover the basics. To use Docker Compose on Unraid, you need to install a community application called “Docker Compose Manager,” developed by “primeval_god.” This is essential to execute the Docker Compose YAML script. More information is available on the Unraid forum.
Understanding the Docker Compose YAML File
First, here is the Docker Compose YAML file I created based on the official example and inspired by how Marius configured email parameters:
version: "3.9"
services:
app:
image: monica
depends_on:
- db
ports:
- 8181:80
environment:
- APP_KEY= # Generate with `echo -n 'base64:'; openssl rand -base64 32`
- DB_HOST=db
- DB_USERNAME=monica
- DB_PASSWORD=secret
- APP_ENV=local
- MAIL_MAILER=smtp
- MAIL_HOST=smtp.gmail.com
- MAIL_PORT=587
- MAIL_USERNAME=Your-own-gmail-address
- MAIL_PASSWORD=Your-own-app-password
- MAIL_ENCRYPTION=tls
- MAIL_FROM_ADDRESS=Your-own-gmail-address
- MAIL_FROM_NAME=Monica
volumes:
- /mnt/user/appdata/monica:/var/www/html/storage
restart: always
db:
image: mariadb:11
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=true
- MYSQL_DATABASE=monica
- MYSQL_USER=monica
- MYSQL_PASSWORD=secret
volumes:
- /mnt/user/appdata/monica-db:/var/lib/mysql
restart: always
Breaking Down the YAML File
I decided to explain this file because it was my first time using Docker Compose, so I had to analyze everything in detail.
Version
version: "3.9"
This line specifies the Docker Compose file format version. I used the one from the official example.
Services
The services section defines the containers we will run.
Application Service
services:
app:
image: monica
...
- image: monica: Specifies the Docker image to use, in this case, ‘monica’.
- depends_on: - db: Ensures the database service (db) starts before the application.
- ports: - 8181:80: Maps port 80 in the container to port 8181 on the host machine (Unraid).
Environment Variables
- APP_KEY: A key for encrypting your application. Generate a 32-character key.
- DB_HOST=db and other database-related variables.
- MAIL_*: Configuration for sending emails via the application.
Volumes
- /mnt/user/appdata/monica:/var/www/html/storage: Maps a directory on your Unraid host to a directory inside the container for persistent storage. By default, Unraid containers will store the datasin /mnt/user/appdata/name_of_your_container
Restart Policy
- restart: always: Ensures the container restarts unless manually stopped.
Database Service
db:
image: mariadb:11
...
- image: mariadb:11: Specifies the MariaDB image for the database.
- environment: Similar to the application service, it configures the database.
- volumes: Ensures data persistence for the database.
Customize Your Variables
Before deploying Monica using Docker Compose, it’s crucial to personalize some values:
- APP_KEY: This is a unique encryption key for your instance.
- Database Credentials: Adjust DB_USERNAME, DB_PASSWORD, and their corresponding values in the db service.
- Email Configuration: Modify the MAIL_* variables with your email settings. This includes details of your email provider and credentials for sending emails from Monica. For email, I use an application-specific password for my Gmail address.
- Volumes: Adjust the paths in the volumes section to suit your preferred storage locations.
- Port Adjustment: Ensure the port defined in ports (e.g., 8181:80) does not conflict with other services on your Unraid server. Replace 8181 with any available port on your host.
Making these adjustments is key to a successful and personalized Monica installation on your Unraid server.
Install Monica on Unraid
Install Docker Compose Manager on Unraid
Find it in the community applications section:
Navigate to the “Docker” tab in the Unraid menu, then at the bottom, after the list of your existing containers, you will find this: “Compose”
Create the Stack Using the YAML File
Click on “ADD NEW STACK” and choose the name of your stack, for example, “Monica”
You should receive a success message after clicking OK
Now let’s modify the stack:
Click on “EDIT STACK”
Choose “COMPOSE FILE”;
Copy the contents of your YAML file and replace everything here. Then click on “SAVE CHANGES”.
Next, you will have the following window:
Replace Icon with some icon URLs, for example, I used these:
Application icon: https://pbs.twimg.com/profile_images/951820722191720450/mtCNuIXX_400x400.jpg
DB icon: https://mariadb.com/wp-content/uploads/2019/11/mariadb-logo-vert_blue-transparent.png
And simply write the URL of your web interface for the application, so it will look something like: http://your_unraid_IP:yourPort/
Leave the shell field empty.
And press OK. Once done, click on “COMPOSE UP” to run docker-compose and install everything:
This will open a window displaying the progress
And you are done!
CONGRATULATIONS! You have successfully self-hosted Monica and learned how to create your docker-compose YAML file and use it!
You can now access Monica at http://your_unraid_IP:yourPort/
.
Following these steps, you should have a fully functional Monica instance on your Unraid server, tailored to your needs. This is a great example of the flexibility Docker provides and an excellent project to get started with Docker Compose!
Enjoy! 😎
AlexIn Tech
Update 04.02.2024: Email Reminders Not Sending – How to Fix?
I encountered this issue as well. After a few days of research, I found a solution that I will share in the next Monica article!
