linuxserver / docker-unifi-network-application

GNU General Public License v3.0
551 stars 40 forks source link

[BUG] this is another derivate from the CLOSED issue related to error from Unifi NatwApp container on Synology #55

Closed juniorUniv closed 4 months ago

juniorUniv commented 5 months ago

Is there an existing issue for this?

Current Behavior

this is another derivate from the CLOSED issue related to error from Unifi NatwApp container on Synology: Defined MONGO_HOST unifi-db is not reachable, cannot proceed.

Deployment managed by Portainer 2,19 /Stacks

Check list: Firewall checked, defined Rule for the subnet from the Compose. Done. Remote control of the MongoDB by MongoDB Compass Desktop ver. As expected. Connection string: mongodb://unifi:COMPOSEPSW@NASIP:27117/?authMechanism=DEFAULT&authSource=unifi image

tested initialized "unifi" DB users: image

same result for the "unifi_stat" DB

test of role: db.getRole("dbOwner") result: { role: 'dbOwner', db: 'unifi' .... Same for the DB unifi_stat

So, port mapping is working and Mongo is available from outside. Manageable.

CLI from NAS environment: docker exec unifi-db env | grep -E 'PUID|PGID' PUID=SAME AS IN the COMPOSE PGID=SAME AS IN the COMPOSE or docker exec unifi-network-application env | grep -E 'PUID|PGID' PUID=SAME AS IN the COMPOSE PGID=SAME AS IN the COMPOSE

both PUID and PGID outputs as expected.

Inside of the Mongo container: getent passwd ... output - is missing the user with defined PUID and GUID there is defined: mongodb:x:999:999::/data/db:/bin/sh which is different from the defined PUID and GUID

Same tested inside the unifi-network-application container, found with the defined PUID and GUID: "abc:x:PUID:GUID::/config:/bin/false unifi:x:101:102::/var/lib/unifi:/usr/sbin/nologin"

Conclusion: DB is accessible from the outside environment, except the Unifi container within the same subnet:

image

Expected Behavior

unif-app conects to unifi-db and creates initialization of the unifi network application

Steps To Reproduce

Created Stack App Template in Portainer using the docker-compose.yml Created init-mongo.js in a directory on NAS Deployed the Stack without any issues. Both Containers shows green check in Containers. DB container shows that user and databases are created and container successfully stores data in provided volumes. APP container is able to create two empty folders "data" and "logs" in provided directory on NAS and is displaying Defined MONGO_HOST unifi-db is not reachable, cannot proceed. in container Logs.

Environment

- OS: Syno DSM 6.2.4.25556
testing environment

CPU architecture

x86-64

Docker creation

version: "3.4"
# Network def
networks:
  unifi-netwapp-net:
    driver: bridge
    ipam:
      config:
        - subnet: "172.30.1.0/16"

services:
# Mongo container part
  unifi-db:
    image: docker.io/mongo:4
    container_name: unifi-db

    ports:
      - 27117:27017

    volumes:
      - ..../mongodb/data:/data/db
      - ..../mongodb/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro

    networks:
      - unifi-netwapp-net

    restart: unless-stopped

    healthcheck:
      test: ["CMD", "mongo", "--eval", "db.adminCommand('ping')"]
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 20s

# Unifi Network App container part
  unifi-network-application:

    depends_on:
      unifi-db:
        condition: service_healthy

    image: lscr.io/linuxserver/unifi-network-application:latest
    container_name: unifi-network-application 

    environment:
      - PUID=XXXX
      - PGID=YYY
      - MONGO_USER=unifi
      - MONGO_PASS=ZZZZZZZ
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27117
      - MONGO_DBNAME=unifi

    volumes:
      - ..../unifi_netw_app:/config

    ports:
      - 8443:8443
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
     # - 1900:1900/udp
      - 8843:8843
      - 8880:8880
      - 6789:6789
      - 5514:5514/udp

    networks:
      - unifi-netwapp-net

    restart: unless-stopped

------------------------------------------------------------
Mongo init-mongo.js:

db.getSiblingDB("unifi").createUser({user: "unifi", pwd: "SAME AS IN the COMPOSE", roles: [{role: "dbOwner", db: "unifi"}]});
db.getSiblingDB("unifi_stat").createUser({user: "unifi", pwd: "SAME AS IN the COMPOSE", roles: [{role: "dbOwner", db: "unifi_stat"}]})

Container logs

[migrations] started
[migrations] no migrations found
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    SAME AS IN the COMPOSE
User GID:    SAME AS IN the COMPOSE
───────────────────────────────────────

*** Waiting for MONGO_HOST unifi-db to be reachable. ***
*** Defined MONGO_HOST unifi-db is not reachable, cannot proceed. ***
github-actions[bot] commented 5 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

drizuid commented 4 months ago

Deployment managed by Portainer 2,19 /Stacks Ill start here - we do not support portainer - https://docs.linuxserver.io/misc/support-policy/

before i close it, i will note something you should've seen while posting all these screenshots.

subnet: "172.30.1.0/16" image

as you can see, you're forcing an ip subnet and it's not being used. this is one of the reasons we do not support portainer. I suggest that you leverage a supported method of deploying your containers, otherwise, you're going to struggle.

All said, the logs tell you the issue, unifi-network-application can't reach the unifi-db. Until you fix that, it will not work.