Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defined MONGO_HOST is not reachable #25

Closed
1 task done
wgstarks opened this issue Oct 25, 2023 · 14 comments
Closed
1 task done

Defined MONGO_HOST is not reachable #25

wgstarks opened this issue Oct 25, 2023 · 14 comments

Comments

@wgstarks
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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
Copy link

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

@aptalca
Copy link
Member

aptalca commented Oct 25, 2023

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

@aptalca aptalca closed this as completed Oct 25, 2023
@LinuxServer-CI LinuxServer-CI moved this from Issues to Done in Issue & PR Tracker Oct 25, 2023
@wgstarks
Copy link
Author

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
Copy link
Author

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
Copy link

h3ndrk commented Oct 27, 2023

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
Copy link
Author

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
Copy link

rsauget commented Oct 29, 2023

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

@rsauget
Copy link

rsauget commented Oct 29, 2023

Actually, I see in the init script here

elif ! nc -w1 "${MONGO_HOST}" ${MONGO_PORT} >/dev/null 2>&1; then
that it runs nc, but I can't find that binary in the image 🤔

@thespad
Copy link
Member

thespad commented Oct 29, 2023

$ docker exec -it unifi bash
root@6bf6ca9fe9cf:/usr/lib/unifi# which nc
/usr/bin/nc

@niki-on-github
Copy link

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
Copy link
Member

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
Copy link
Author

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
Copy link

myazaki commented Nov 27, 2023

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

8 participants