Docker Compose Deployment Guide for Lemmy Communities

Running an independent community platform requires a dependable, repeatable deployment process. For administrators setting up a federated link aggregator, deploying the platform via container orchestration provides isolation, predictable dependency management, and straightforward software upgrades. Following the official containerized workflow ensures your server components operate smoothly alongside a reverse proxy and a tuned database engine.
1. Preparing the Host Environment and Directories
Before launching services, you must prepare the server with container tools. The deployment requires Docker and a modern Compose installation, specifically docker-compose version 2.0 or higher. Operating system repositories package these components differently:
- On Ubuntu systems, administrators can install the necessary packages directly from the command line by running
apt install docker-compose-v2 docker.io. - On Debian systems, installation requires following Docker's official setup instructions and configuring their custom apt repository.
Once the prerequisites are present, create a dedicated directory to store the deployment files. The absolute path does not matter; placing the files under a directory such as /srv/lemmy or any preferred storage location works fine. Navigate into that directory before retrieving configuration assets.
2. Downloading Lemmy Configuration Files
Lemmy relies on several interrelated configuration templates to handle backend logic, frontend routing, and container networking. As outlined in the Lemmy Install with Docker guide, administrators must fetch the default configuration files directly into the setup directory using wget:
- Download the container orchestration file from the documentation repository:
wget https://raw.githubusercontent.com/LemmyNet/lemmy-docs/main/assets/docker-compose.yml - Retrieve the primary application settings file:
wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/examples/config.hjson -O lemmy.hjson - Fetch the internal web server configuration:
wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/templates/nginx_internal.conf - Download the internal proxy parameters:
wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/files/proxy_params
Reviewing our Lemmy: At-a-Glance Profile of the Federated Discussion Platform can help new operators understand how these services work together across federated networks.
3. Configuring Environment Variables and Storage Permissions
Open docker-compose.yml and lemmy.hjson in a text editor. Throughout both files, locate all placeholders marked with double curly brackets. Replace every instance of the domain placeholder with your actual Lemmy community domain name, and replace the database password variable with a strong, random password. For deeper tailoring, further adjustments can be made directly inside lemmy.hjson.
Next, configure the internal resolver within nginx_internal.conf. Replace the resolver placeholder with 127.0.0.11. For administrators running RedHat distributions, use 10.89.0.1 instead.
Storage permissions must also be established for pict-rs, the media storage service. Create the local volume folder and assign ownership by running:
mkdir -p volumes/pictrs
sudo chown -R 991:991 volumes/pictrs
Using the user identifier 991 ensures the containerized image host has appropriate read and write access to the filesystem.
4. Applying Postgres Database Tweaks
Lemmy stores discussion threads, community boards, and identity records within a PostgreSQL database. To enhance throughput under operational loads, the deployment supports an external tuning file. Administrators can download the template with wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/examples/customPostgresql.conf.
To calculate optimized database settings tailored to your hardware resources, the official documentation suggests using the online database tuning utility at https://pgtune.leopard.in.ua/. You can enter your specific server specifications into the tool and place the resulting values into your custom database configuration file before starting the container stack.
5. Reverse Proxy Setup and Federation Headers
To expose the platform safely to the internet, administrators should place an edge reverse proxy in front of the application. An optional Nginx template is available via wget https://raw.githubusercontent.com/LemmyNet/lemmy-ansible/main/templates/nginx.conf, which can be placed in /etc/nginx/sites-enabled, though alternatives like Caddy also serve as simple reverse proxies. You must edit the template to supply your domain and chosen port settings, alongside setting up TLS certificates with Let's Encrypt. Learn more about certificate automation in our guide to Free HTTPS for Your Forum With Let's Encrypt.
Preserving HTTP headers is critical for inter-server communication. According to the Lemmy Install with Docker instructions, administrators must not modify any headers that form part of the cryptographic signature required for federation. In particular, the reverse proxy must pass the Host header through completely unmodified.
6. Starting the Stack and Performing Updates
Once the configurations, proxy rules, and storage ownership permissions are in place, start the containers by running:
docker compose up -d
On the host server, the web interface service (lemmy-ui) becomes accessible locally at http://localhost:{{ lemmy_port }}, and external visitors can browse the site over secure HTTPS using your configured domain once the reverse proxy is active.
Maintaining the platform requires only minor updates to container image tags. To upgrade, edit docker-compose.yml to reference new container versions (for instance, changing an image tag such as dessalines/lemmy:0.19.4 to dessalines/lemmy:0.19.5). If specific releases require additional migration steps, those instructions appear in official release announcements. Finally, download the new layers and recreate the containers:
docker compose pull
docker compose up -d
Sources
Information in this guide is sourced directly from the official project documentation:
Published October 28, 2026. No affiliate links on this page. Facts come from the sources linked above; check them for updates.