Home > Software > How to Deploy Umami with Docker Compose: A Seamless Guide for Self-Hosted Web Analytics

How to Deploy Umami with Docker Compose: A Seamless Guide for Self-Hosted Web Analytics

Anastasios Antoniadis

Discover the simple steps to deploy Umami, the open-source web analytics solution, using Docker Compose. Follow our guide to easily set up Umami and gain insightful analytics for your websites without compromising user privacy.

Docker (1)

Umami is a simple, fast, open-source web analytics solution allowing website owners to track visits without compromising user privacy. Unlike other analytics platforms that can be complex and invasive, Umami provides a straightforward and user-friendly interface for monitoring website traffic data, making it an attractive option for those looking to move away from Google Analytics or similar services. This guide will walk you through setting up Umami using Docker Compose, enabling you to host your own web analytics platform efficiently.

Prerequisites

Before you start, ensure you have:

  • Docker installed on your system.
  • Docker Compose installed on your system.
  • Basic understanding of Docker concepts and the YAML syntax used in Docker Compose files.

Step 1: Create a Docker Compose File

Create a directory dedicated to your Umami setup. This directory will contain your Docker Compose file (docker-compose.yml) and any additional configuration files or directories you might need.

mkdir umami-docker && cd umami-docker

Create the docker-compose.yml file:

touch docker-compose.yml

Open this file in a text editor and insert the following configuration:

version: '3.8'
services:
  umami-db:
    image: postgres:13-alpine
    container_name: umami-db
    environment:
      POSTGRES_DB: umamidb
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: umamisecurepassword
    volumes:
      - umami-db-data:/var/lib/postgresql/data

  umami:
    image: ghcr.io/mikecao/umami:postgresql-latest
    container_name: umami
    depends_on:
      - umami-db
    environment:
      DATABASE_URL: postgresql://umami:umamisecurepassword@umami-db/umamidb
      DATABASE_TYPE: postgresql
      HASH_SALT: somesecretsalt
    ports:
      - "3000:3000"
    restart: always

volumes:
  umami-db-data:

Configuration Explained:

  • umami-db: Sets up a PostgreSQL database container for Umami, using Alpine Linux for a minimal footprint. Environment variables are used to define the database name, user, and password.
  • umami: Configures the Umami application container, linking it to the PostgreSQL service for data storage. It sets the DATABASE_URL, DATABASE_TYPE, and HASH_SALT environment variables necessary for Umami to connect to the database and secure user sessions.
  • volumes: Declares a named volume (umami-db-data) for persisting the PostgreSQL database data, ensuring data retention across container restarts.
  • ports: Exposes port 3000 on the host, mapping it to Umami’s default port inside the container, allowing access to the Umami web interface.

Step 2: Launch Umami

With your docker-compose.yml file ready, start the Umami service by running:

docker compose up -d

This command will download the necessary Docker images (if not already present) and start the Umami and PostgreSQL containers in detached mode.

Step 3: Access Umami

Once the containers are up and running, access the Umami web interface by navigating to http://localhost:3000 in your web browser. The default login credentials for Umami are:

  • Username: admin
  • Password: umami

It is strongly recommended to change the default password immediately after the first login for security reasons.

Step 4: Configure and Use Umami

After logging in, you can start configuring Umami to track your websites. This involves adding websites to your Umami dashboard and integrating the provided tracking script into your websites. Umami offers detailed analytics, including page views, device types, referral sources, and more, all displayed in a clean, intuitive interface.

Conclusion

Deploying Umami with Docker Compose offers a straightforward and efficient method for setting up a privacy-friendly web analytics platform. By following the steps outlined in this guide, you can have your own self-hosted analytics solution up and running quickly, providing you with valuable insights into your website traffic without compromising user privacy. Docker Compose simplifies the management of Umami services, making it easy to deploy, scale, and maintain your analytics infrastructure. Whether you’re a blogger, a small business owner, or a web developer, Umami provides the tools you need to understand your audience better while respecting their privacy.

Anastasios Antoniadis
Follow me
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x