Skip to content

[BUG] <title> Lost contact with adopted devices after reboot #141

@torbjorn

Description

@torbjorn

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I launched the unifi-network-application using docker compose as recomended in the docs. I also adopted by 2 AP discs (AC PRO) and a switch (US 8)

docker_compose_logs.txt.gz

una_logs.txt.gz

today.

Later after a simple docker compose down and docker compose up, it had lost contact with all three devices (though I can still log on as normal on the web interface). It re-adopted the switch relatively quickly, but the two AP disks were stuck in an "Adopting" and "Offline" loop.

I can not ssh into them again.

docker-compose.yml:

services:
  unifi-db:
    image: docker.io/mongo:8.0.5-noble
    container_name: unifi-db
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_ROOT_USER:-root}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD:-xxx}
      - MONGO_USER=${MONGO_USER:-unifi}
      - MONGO_PASS=${MONGO_PASS:-yyy}
      - MONGO_DBNAME=${MONGO_DBNAME:-unifi}
      - MONGO_AUTHSOURCE=admin
    volumes:
      - ${DATA_DIR:-${HOME}/.local/share/unifi-network-application}/data:/data/db
      - ${DATA_DIR:-${HOME}/.local/share/unifi-network-application}/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh:ro
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "'db.runCommand(\"ping\").ok'", "--quiet"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    networks:
      - traefik_traefiknet
    mem_limit: 1024M

  unifi-network-application:
    image: lscr.io/linuxserver/unifi-network-application:9.0.114
    container_name: unifi-network-application
    environment:
      - PUID=${PUID:-1001}
      - PGID=${PGID:-1001}
      - TZ=${TZ:-Etc/UTC}
      - MONGO_USER=${MONGO_USER:-unifi}
      - MONGO_PASS=${MONGO_PASS:-yyy}
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27017
      - MONGO_DBNAME=${MONGO_DBNAME:-unifi}
      - MONGO_AUTHSOURCE=admin
      - MEM_LIMIT=${UNIFI_MEM_LIMIT:-1024}
      - MEM_STARTUP=${UNIFI_MEM_STARTUP:-1024}
      - MONGO_TLS=${MONGO_TLS:-}
    volumes:
      - ${DATA_DIR:-${HOME}/.local/share/unifi-network-application}/config:/config
    ports:
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
      - 1900:1900/udp
      - 8880:8880
      - 6789:6789
      - 5514:5514/udp
      - 8443:8443
    restart: unless-stopped
    depends_on:
      unifi-db:
        condition: service_healthy
    networks:
      - traefik_traefiknet
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.unifi.rule=Host(`example.com`)"
      - "traefik.http.routers.unifi.entrypoints=websecure"
      - "traefik.http.routers.unifi.tls=true"
      - "traefik.http.routers.unifi.service=unifi"
      - "traefik.http.routers.unifi.tls.certresolver=myresolver"
      - "traefik.http.services.unifi.loadbalancer.server.port=8443"
      - "traefik.http.services.unifi.loadbalancer.server.scheme=https"
      - "traefik.http.services.unifi.loadbalancer.serversTransport=insecuretransport@file"
networks:
  traefik_traefiknet:
    external: true

init-mongo.sh

#!/bin/bash

if which mongosh > /dev/null 2>&1; then
  mongo_init_bin='mongosh'
else
  mongo_init_bin='mongo'
fi
"${mongo_init_bin}" <<EOF
use ${MONGO_AUTHSOURCE}
db.auth("${MONGO_INITDB_ROOT_USERNAME}", "${MONGO_INITDB_ROOT_PASSWORD}")
db.createUser({
  user: "${MONGO_USER}",
  pwd: "${MONGO_PASS}",
  roles: [
    { db: "${MONGO_DBNAME}", role: "dbOwner" },
    { db: "${MONGO_DBNAME}_stat", role: "dbOwner" }
  ]
})
db.grantRolesToUser("${MONGO_USER}", [{ role: "clusterMonitor", db: "admin" }]);
EOF

unifi-network-application.service

[Unit]
Description=Unifi Network Application Service
After=network-online.target
Documentation=https://docs.linuxserver.io/images/docker-unifi-network-application

[Service]
Type=simple
WorkingDirectory=/home/lindahl/.local/share/unifi-network-application
Environment="COMPOSE_HTTP_TIMEOUT=300"

# Ensure Docker is running before starting
ExecStartPre=/bin/bash -c 'until /usr/bin/docker info >/dev/null 2>&1; do sleep 1; done'

# Create .env file if not exists with default values
ExecStartPre=/bin/bash -c 'if [ ! -f .env ]; then echo "DATA_DIR=/home/lindahl/.local/share/unifi-network-application" > .env; fi'

ExecStart=/usr/bin/docker compose up
ExecStop=/usr/bin/docker compose down --timeout 180

# Restart policy
Restart=always
RestartSec=10

# Limits
TimeoutStartSec=180s
TimeoutStopSec=180s
LimitNOFILE=infinity
LimitNPROC=infinity

[Install]
WantedBy=multi-user.target

This is my device view in the controller:

Image

Expected Behavior

Server restarts and all devices are ready since they were already adopted before the restart

Steps To Reproduce

  1. docker compose up
  2. adopt devices
  3. docker compose down
  4. docker compose up
  5. observe that devices have to be readopted

Environment

- OS: ubuntu noble
- How docker service was installed: docker compose file as shown

CPU architecture

x86-64

Docker creation

systemctl start --user unifi-network-application

This in turn just does a docker compose up

Container logs

I attached log files further up, they are roughly 4k lines.

I have done docker compose logs and journalctl --user-unit=unifi-network-application

Or.. I tried to add them (tar.gz files) but I'm not sure if anything happened

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions