I run Unifi network gear in my house. As I have multiple wireless access points, I use a controller to manage them so clients can seamlessly roam between them.

I run Unifi’s controller software as a Docker container (from here and here) to save myself from running Yet Another Appliance™ and paying for more hardware. I’ve been running v6 for a while, but recently upgraded to v8.

These are my notes to myself for how I set this up.

Everything is stored here on Zeus: /home/simas/docker/unifi-network-application

These are the two critical files: docker-compose.yml and init-mongo.sh

docker-compose.yml:

services:
  unifi-db:
    image: mongo:7.0.12
    mem_limit: 1024m
    command: --wiredTigerCacheSizeGB 0.25
    restart: unless-stopped
    container_name: unifi-db
    volumes:
      - /home/simas/docker/unifi-network-application/db:/data/db
      - /home/simas/docker/unifi-network-application/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.js:ro

  unifi-network-application:
    image: lscr.io/linuxserver/unifi-network-application:8.3.32
    mem_limit: 2048m
    container_name: unifi-network-application
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - MONGO_USER=unifi
      - MONGO_PASS=REDACTED
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27017
      - MONGO_DBNAME=unifi
      - MEM_LIMIT=1024 #optional
      - MEM_STARTUP=1024 #optional
      - MONGO_TLS= #optional
      - MONGO_AUTHSOURCE= #optional
    volumes:
      - /home/simas/docker/unifi-network-application:/config
    ports:
      - 8443:8443
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
      - 1900:1900/udp #optional
      - 8843:8843 #optional
      - 8880:8880 #optional
      - 6789:6789 #optional
      - 5514:5514/udp #optional
    restart: unless-stopped

init-mongo.sh

db.getSiblingDB("unifi").createUser({user: "unifi", pwd: "REDACTED", roles: [{role: "dbOwner", db: "unifi"}]});
db.getSiblingDB("unifi_stat").createUser({user: "unifi", pwd: "REDACTED", roles: [{role: "dbOwner", db: "unifi_stat"}]});

Once those files are created, start services with docker compose up -d.