Skip to content

Setup UniFi Controller

Overview

The Unifi-network-application software is a powerful, enterprise wireless software engine ideal for high-density client deployments requiring low latency and high uptime performance.

Important Docker Files

mongo.js File

mongo.js
db.getSiblingDB("").createUser({user: "", pwd: "", roles: [{role: "dbOwner", db: ""}, {role: "dbOwner", db: ""}]});exit

.env file

.env
NAME=unifi
ID=1000
MEM=1024
TZ=America/New_York
DOMAIN=
APPDATA=
DB_USER=unifi
DB_NAME=unifi
DB_PASS=

docker-compose.yml file

docker-compose.yml
services:
  unifi:
    container_name: ${NAME}
    image: lscr.io/linuxserver/unifi-network-application
    restart: unless-stopped
    environment:
      PUID: ${ID}
      PGID: ${ID}
      MEM_LIMIT: ${MEM}
      TZ: ${TZ}
      MONGO_USER: ${DB_USER}
      MONGO_PASS: ${DB_PASS}
      MONGO_HOST: ${NAME}-db
      MONGO_PORT: 27017
      MONGO_DBNAME: ${DB_NAME}
    volumes:
      - ${APPDATA}/${NAME}/config:/config
    networks:
      - proxy
      - internal-db
    depends_on:
      - ${NAME}-db
    labels:
        com.centrylinklabs.watchtower.enable: true
  unifi-db:
    image: mongo
    container_name: ${NAME}-db
    volumes:
      - ${APPDATA}/${NAME}/config-db:/data/db
      - ${APPDATA}/${NAME}/mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
    restart: unless-stopped
    networks:
      - proxy
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongosh ${NAME}-db:27017/${DB_NAME}
        --quiet
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 40s
    security_opt:
      - seccomp:unconfined
    labels:
      com.centrylinklabs.watchtower.enable: true
networks:
  proxy:
    external: true
  internal-db:
    external: true

Start the Container

Start the Container
docker compose up -d