Introduction

Gotify is a lightweight, self-hosted notification service designed for ease of use and minimal resource consumption. In this guide, we’ll walk through setting up Gotify with Docker, using PostgreSQL as the database backend.

Prerequisites

  • A server with Docker and Docker Compose installed
  • Basic familiarity with command-line operations
  • A reverse proxy setup (e.g., Nginx, Caddy, or Traefik) if you want to secure access

Step 1: Prepare the Environment Variables

Create a .env file in your project directory to store environment variables:

POSTGRES_USER=gotify
POSTGRES_DB=gotify
POSTGRES_PASSWORD=CHANGEME    # generate with the command `openssl rand -hex 32`
TZ=America/New_York   # change to your preference

Make sure to replace CHANGEME with a secure password generated using:

openssl rand -hex 32

Step 2: Define the Docker Compose Configuration

Create a docker-compose.yml file in the same directory:

---
services:

  gotify:
    image: ghcr.io/gotify/server:2.6
    restart: always
    ports:
      - 6886:80
    environment:
      - "GOTIFY_DATABASE_DIALECT=postgres"
      - "GOTIFY_DATABASE_CONNECTION=host=postgres\ port=5432\ user=${POSTGRES_USER}\ dbname=${POSTGRES_DB}\ password=${POSTGRES_PASSWORD}\ sslmode=disable"
      - "GOTIFY_REGISTRATION=false"
      - TZ
    depends_on:
      postgres:
        condition: service_healthy   
    volumes:
      - gotify:/app/data
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"

  postgres:
    image: 'postgres:17.2'
    restart: always
    environment:
      - POSTGRES_DB
      - POSTGRES_PASSWORD
      - POSTGRES_USER
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 10s
      timeout: 5s
      retries: 5      
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
   
volumes:
  gotify:
  postgres_data:

Step 3: Start the Gotify Service

Run the following command to start the service:

docker compose up -d

This will download the required images and start Gotify along with PostgreSQL.

Step 4: Access the Gotify Web Interface

Once the containers are running, open your web browser and navigate to:

http://your-server-ip:6886

Log in with the default credentials:

Username: admin
Password: admin

Change the admin password immediately after logging in.

Step 5: Secure Gotify with a Reverse Proxy

For production use, it’s recommended to hide Gotify behind a reverse proxy such as Nginx, Caddy, or Traefik. Since most self-hosting enthusiasts already have a reverse proxy set up, this guide does not cover those details. However, ensure that TLS encryption is configured if you expose Gotify to the internet.

Conclusion

You now have a fully functional Gotify notification service running on Docker with PostgreSQL. This setup allows you to send and manage notifications efficiently while keeping full control over your data.

For further customization and API usage, refer to the official Gotify documentation.