linuxserver / docker-unifi-network-application

GNU General Public License v3.0
553 stars 41 forks source link

Defined MONGO_HOST is not reachable #25

Closed wgstarks closed 8 months ago

wgstarks commented 8 months ago

Is there an existing issue for this?

Current Behavior

I am trying to migrate from LSIO Unifi Controller on Unraid to LSIO UNA.

I have installed MongoDB official docker with the following docker run- docker run -d --name='unifi-network-application' --net='bridge' -e TZ="America/New_York" -e HOST_OS="Unraid" -e HOST_HOSTNAME="Brunnhilde" -e HOST_CONTAINERNAME="unifi-network-application" -e 'MONGO_USER'='unifi' -e 'MONGO_PASS'='password' -e 'MONGO_HOST'='unifi-db' -e 'MONGO_PORT'='27017' -e 'MONGO_DBNAME'='unifi' -e 'MEM_LIMIT'='1024' -e 'MEM_STARTUP'='1024' -e 'MONGO_TLS'='' -e 'MONGO_AUTHSOURCE'='' -e 'PUID'='99' -e 'PGID'='100' -e 'UMASK'='022' -l net.unraid.docker.managed=dockerman -l net.unraid.docker.icon='https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/unifi-network-application-icon.png' -p '8443:8443/tcp' -p '3478:3478/udp' -p '10001:10001/udp' -p '8080:8080/tcp' -p '1900:1900/udp' -p '8843:8843/tcp' -p '8880:8880/tcp' -p '6789:6789/tcp' -p '5514:5514/udp' -v '/mnt/cache/appdata/unifi-network-application':'/config':'rw' 'lscr.io/linuxserver/unifi-network-application' 1e4456c02dc6cc046c505304d5fc68e61891b46b3d0cf4b4d2a995d360ccd312

The command finished successfully!

I have installed UNA with the following docker run- docker run -d --name='unifi-network-application' --net='bridge' -e TZ="America/New_York" -e HOST_OS="Unraid" -e HOST_HOSTNAME="Brunnhilde" -e HOST_CONTAINERNAME="unifi-network-application" -e 'MONGO_USER'='unifi' -e 'MONGO_PASS'='password' -e 'MONGO_HOST'='unifi-db' -e 'MONGO_PORT'='27017' -e 'MONGO_DBNAME'='unifi' -e 'MEM_LIMIT'='1024' -e 'MEM_STARTUP'='1024' -e 'MONGO_TLS'='' -e 'MONGO_AUTHSOURCE'='' -e 'PUID'='99' -e 'PGID'='100' -e 'UMASK'='022' -l net.unraid.docker.managed=dockerman -l net.unraid.docker.icon='https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/unifi-network-application-icon.png' -p '8443:8443/tcp' -p '3478:3478/udp' -p '10001:10001/udp' -p '8080:8080/tcp' -p '1900:1900/udp' -p '8843:8843/tcp' -p '8880:8880/tcp' -p '6789:6789/tcp' -p '5514:5514/udp' -v '/mnt/cache/appdata/unifi-network-application':'/config':'rw' 'lscr.io/linuxserver/unifi-network-application' 1e4456c02dc6cc046c505304d5fc68e61891b46b3d0cf4b4d2a995d360ccd312

The command finished successfully!

When I try to start the UNA docker the log shows that the host db is unreachable. I suspect that my MongoDB docker is missing a variable for the host db but I'm unable to find the proper variable.

Expected Behavior

No response

Steps To Reproduce

install docker

Environment

- OS:
- How docker service was installed:

CPU architecture

x86-64

Docker creation

docker run
  -d
  --name='unifi-network-application'
  --net='bridge'
  -e TZ="America/New_York"
  -e HOST_OS="Unraid"
  -e HOST_HOSTNAME="Brunnhilde"
  -e HOST_CONTAINERNAME="unifi-network-application"
  -e 'MONGO_USER'='unifi'
  -e 'MONGO_PASS'='password'
  -e 'MONGO_HOST'='unifi-db'
  -e 'MONGO_PORT'='27017'
  -e 'MONGO_DBNAME'='unifi'
  -e 'MEM_LIMIT'='1024'
  -e 'MEM_STARTUP'='1024'
  -e 'MONGO_TLS'=''
  -e 'MONGO_AUTHSOURCE'=''
  -e 'PUID'='99'
  -e 'PGID'='100'
  -e 'UMASK'='022'
  -l net.unraid.docker.managed=dockerman
  -l net.unraid.docker.icon='https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/unifi-network-application-icon.png'
  -p '8443:8443/tcp'
  -p '3478:3478/udp'
  -p '10001:10001/udp'
  -p '8080:8080/tcp'
  -p '1900:1900/udp'
  -p '8843:8843/tcp'
  -p '8880:8880/tcp'
  -p '6789:6789/tcp'
  -p '5514:5514/udp'
  -v '/mnt/cache/appdata/unifi-network-application':'/config':'rw' 'lscr.io/linuxserver/unifi-network-application'
1e4456c02dc6cc046c505304d5fc68e61891b46b3d0cf4b4d2a995d360ccd312

Container logs

text  error  warn  system  array  login  

[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:    99
User GID:    100
───────────────────────────────────────

*** Defined MONGO_HOST is not reachable, cannot proceed. ***
github-actions[bot] commented 8 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.

aptalca commented 8 months ago

You need to put them on a user defined bridge network. The default bridge does not allow container to container name resolution

wgstarks commented 8 months ago

You need to put them on a user defined bridge network. The default bridge does not allow container to container name resolution

Thanks. I’ll try that.

wgstarks commented 8 months ago

You need to put them on a user defined bridge network. The default bridge does not allow container to container name resolution

This didn't work. I created a custom docker network with the command docker network create unifi Edited both dockers to use Custom: unifi. Still getting the same error in UNA.

h3ndrk commented 8 months ago

Same error here. I used a docker-compose.yml with the MongoDB and UniFi with depends_on: but it seems that the MongoDB is seen as ready too early and Docker Compose already starts the UniFi service. If starting the services manually after each other with some delay, it works for me.

wgstarks commented 8 months ago

Same error here. I used a docker-compose.yml with the MongoDB and UniFi with depends_on: but it seems that the MongoDB is seen as ready too early and Docker Compose already starts the UniFi service. If starting the services manually after each other with some delay, it works for me.

This doesn’t work for me. The mongodb docker has been running for several days but I still get an error when trying to start UNA.

rsauget commented 8 months ago

Same issue here. If I docker exec into the container to run a wget $MONGO_HOST:$MONGO_PORT it works, really confusing

rsauget commented 8 months ago

Actually, I see in the init script here https://github.com/linuxserver/docker-unifi-network-application/blob/d571bd1aa59dd3c1c0c8d56d2b5f6e98bad45575/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run#L26 that it runs nc, but I can't find that binary in the image 🤔

thespad commented 8 months ago
$ docker exec -it unifi bash
root@6bf6ca9fe9cf:/usr/lib/unifi# which nc
/usr/bin/nc
niki-on-github commented 8 months ago

Same issue. After using healthcheck in for mongo + depends_on the Host can be resolved. I think we should solve the actual problem in init script. Here we need to check with a loop for the host to become available and not block with sleep infinity forever. Why was this issue closed without resolving the problem?

j0nnymoe commented 8 months ago

It was closed because the original issue was the user didn't have the containers on the same custom docker bridge so they couldn't talk with each other.

wgstarks commented 8 months ago

It was closed because the original issue was the user didn't have the containers on the same custom docker bridge so they couldn't talk with each other.

While that was part of the problem, fixing it didn’t resolve the issue. I was able to resolve it using the MongoDB init js file instead of the init variables in the MongoDB docker though. So I guess the original issue is resolved.

myazaki commented 7 months ago

Hi all having the same issue. *** Defined MONGO_HOST unifi-db is not reachable, cannot proceed. *** Below is my docker compose file. I browsed all the issues back and forth and could not get into any working config for me on my Synology NAS DS-720+ x86-64bit. Controller works just fine, trying to migrate. I am kind of frustrated not getting it to work. Any ideas?

version: "2.1"
services:    
  unifi-app:
    image: lscr.io/linuxserver/unifi-network-application:latest
    container_name: unifi-app
    depends_on:
      - unifi-db
    networks:
      - unifi-net
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Prague
      - MONGO_USER=unifi
      - MONGO_PASS=unifi
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27017
      - MONGO_DBNAME=unifi
    volumes:
      - /volume1/docker/unifi-app/app:/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

  unifi-db:
    image: mongo:4.4.25
    container_name: unifi-db
    networks:
      - unifi-net
    ports:
     - 27017:27017
    volumes:
      - /volume1/docker/unifi-app/db/data:/data/db
      - /volume1/docker/unifi-app/db/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
      - /volume1/docker/unifi-app/db/config:/data/configdb
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "mongo", "--eval", "db.adminCommand('ping')"]
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 20s

networks:
  unifi-net:
    driver: bridge

init-mongo.js

db.getSiblingDB("unifi").createUser({user: "unifi", pwd: "unifi", roles: [{role: "dbOwner", db: "unifi"}]});
db.getSiblingDB("unifi_stat").createUser({user: "unifi", pwd: "unifi", roles: [{role: "dbOwner", db: "unifi_stat"}]});
j0nnymoe commented 7 months ago

@myazaki please open a new issue and provide the information requested.