This guide provides a full Ansible playbook to deploy Listmonk with Docker Compose on Debian 10+, Ubuntu LTS, and RHEL 9+ compatible hosts.
listmonk.example.com)- name: Deploy Listmonk
hosts: listmonk
become: true
vars:
app_root: /opt/listmonk
app_port: 9000
db_password: "ChangeMe123!"
listmonk_version: "latest"
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create application directory
file:
path: "{{ app_root }}"
state: directory
mode: "0755"
- name: Write Docker Compose file
copy:
dest: "{{ app_root }}/docker-compose.yml"
mode: "0644"
content: |
services:
listmonk:
image: listmonk/listmonk:{{ listmonk_version }}
container_name: listmonk
restart: unless-stopped
ports:
- "{{ app_port }}:9000"
environment:
- LISTMONK_app__address=0.0.0.0:9000
- LISTMONK_db__host=db
- LISTMONK_db__port=5432
- LISTMONK_db__user=listmonk
- LISTMONK_db__password={{ db_password }}
- LISTMONK_db__database=listmonk
volumes:
- ./config.toml:/listmonk/config.toml
depends_on:
- db
db:
image: postgres:15
container_name: listmonk-db
restart: unless-stopped
environment:
- POSTGRES_DB=listmonk
- POSTGRES_USER=listmonk
- POSTGRES_PASSWORD={{ db_password }}
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:
- name: Initialize database (first run only)
command: docker compose run --rm listmonk ./listmonk --install
args:
chdir: "{{ app_root }}"
register: init_result
failed_when: init_result.rc != 0 and 'already installed' not in init_result.stderr
ignore_errors: true
- name: Start application stack
command: docker compose up -d
args:
chdir: "{{ app_root }}"
listmonk/listmonk on Docker Hublatesthttp://your-server:9000Any questions?
Feel free to contact us. Find all contact information on our contact page.