Nov 17, 2022 3 min read

How To Install Listmonk With Docker

Want to run your own newsletter? Listmonk is a self-hosted free and open-source, high-performance mailing list and newsletter manager.

How To Install Listmonk With Docker
listmonk docker
Table of Contents

Are you running your own website and looking to host your own newsletter service? I present Listmonk to you, a self-hosted free and open-source, high-performance mailing list and newsletter manager. It is written in go and utilizes PostgreSQL database. You can connect an SMTP service such as Amazon SES or any other SMTP service to Listmonk and start managing your website's newsletter subscribers. Let's jump into the setup process with docker.

Ensure that you have docker and docker-compose installed or use these steps to install docker.

How To Install Docker and Docker-Compose On Ubuntu Linux
In this tutorial, we are going to install docker and docker-compose on either a raspberry pi4 running Ubuntu Linux or an AMD64 system running Ubuntu Linux.

Also Read:

How To Install Mautic With Docker
Self-host your newsletter with Mautic, an excellent self-hosted open-source option for you. Let’s jump in and set up Mautic with docker.

Docker Compose And Config

The first will be to copy the docker-compose.yml & config.toml config file to your folder on your docker host where all your docker-compose folders are stored. Create the two files mentioned in the previous sentence and copy the below code to both files.

docker-compose.yml

version: "3.7"

services:
  db:
    image: postgres:13
    container_name: listmonk-db
    ports:
      - "5432:5432"
    networks:
      - listmonk
    environment:
      - POSTGRES_PASSWORD=listmonk
      - POSTGRES_USER=listmonk
      - POSTGRES_DB=listmonk
    restart: always
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U listmonk"]
      interval: 10s
      timeout: 5s
      retries: 6
    volumes:
      - /docker/listmonk/postgresql/:/var/lib/postgresql/data

  app:
    image: listmonk/listmonk:latest
    container_name: listmonk-web
    restart: always
    ports:
      - "9800:9000"
    command: [sh, -c, "yes | ./listmonk --install --config config.toml && ./listmonk --config config.toml"]
    networks:
      - listmonk
    environment:
      - TZ=Etc/UTC
    depends_on:
      - db
    volumes:
      - /docker/listmonk/config/config.toml:/listmonk/config.toml
      - /docker/listmonk/static:/listmonk/static

networks:
  listmonk:

config.toml

[app]
address = "0.0.0.0:9000"
admin_username = "your_username"
admin_password = "your_password"

# Database.
[db]
host = "listmonk-db"
port = 5432
user = "listmonk"
password = "listmonk"
database = "listmonk"
ssl_mode = "disable"
max_open = 25
max_idle = 25
max_lifetime = "300s"

Copy config to your docker persistent data folder

The next step is to create the directories if you do not have them created and ensure that you tweaked the folder's permissions for docker usage. Your folders can be anything you want to create or you can follow my structure in the docker-compose file:

sudo mkdir docker
sudo mkdir /docker/listmonk
sudo mkdir /docker/listmonk/config

Copy your config.toml file to the config folder:

sudo cp config.toml /docker/listmonk/config/

Setup Listmonk And Database

Once all the above steps have been completed you should navigate to the folder hosting your the docker-compose.yml file and run docker-compose up to pull the images and set up the stack:

docker-compose up -d

Once done you can confirm if your containers are running with the docker ps command or you can navigate to the docker host IP and port number bound to your web application in this specific instance it is <ip_addr>:9800 via your web browser and you should get to a login screen where you log in with the credentials you defined in the config.toml file. Once logged in you can navigate through the dashboard and configure all your settings.

Listmonk Login
Listmonk Dashboard

Conclusion

In conclusion, I really like Listmonk as it is easy to set up and a lightweight application stack for your compute resources. If you enjoyed this article consider signing up for our newsletter and don't forget to share it with people that would find it helpful. Leave a comment below with a tutorial you would like us to cover.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Opensource Geeks.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.