-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
[Request] for an example of Unifi-Network-Application from linuxserver.io #16
Comments
Hi @Ciberbago, thanks for reaching out. The documentation provided by Linuxserver is quite good. However, I understand where you are coming from. Adjusting the docker-compose.yml with a proper mongo db service is not that straight forward. Nonetheless, I've done some research and crafted a (hopefully) working compose file:
Note that you are mounting a file named The file contains the following content:
These parameters are also referenced in the As long as the given example is unconfirmed, I will not include it to this repository. |
Hello! Thank you for all your work, I wanted to apologize, I've been busy and just had the time to check it out. I tried just like you said and it worked beautifully. I created the file with the config, then the docker compose mounting the config, db folders and the init file. Using stacks on portainer I started the stack and everything just worked. I just had to backup my old unifi controller server and restore it in this new one. So... I think you could include this one on your examples as a success :) |
Thank you for the confirmation. Added to the repo. See 910b53c |
Trying to use this, but wondering where the init-mongo.js file should be placed so that it is found by portainer when the initial deployment takes place? |
You specify the path to the init file via the compose volume key. The init file basically is stored in the same directory where you put the compose file. I personally do not like starting stacks within Portainer as it abstracts the file system. You would have to manually put the init file somewhere on your server where portainer can access it and then define the absolute path in the compose file. |
Thanks for the reply. I had put init-mongo.js in /home/pi, and put that path in the compose statements, but Mongo doesn't seem to have got the right connections. The container log has the following:- |
May remove all volume bind mounts and try again, if you have previously started the container stack. This removes the database and you can start freshly. Ensure to only adjust the left side of the bind mount definition, which is your host's path. The right side stays the same; as it is the internal docker container path. |
Anyone know how to get it to work on a pi? I've modified it
it runs, but it restarts in docker without a log or error message. :( |
You'd have to use a proper ARM image of MongoDB, which seems to not exist anymore. Maybe you can use the image https://forums.docker.com/t/mongo-db-raspberry-pi4/138908/2 Otherwise, ensure that you RPi runs an ARM64 or AARCH64 OS. Then the provided example should just work. |
I was trying this on pi, except with mongo 3.6. I used @Ciberbago's compose file, only changing the mongo image and volume mappings and I'm getting this error:
Anyone have any ideas to fix? I've tried other versions of a compose file with the linuxserver image but no matter what I've tried, I keep running into this same error. Banging my head against the wall here on why this doesn't just work. Hers's my docker-compose.yml:
|
Maybe this helps: https://discourse.linuxserver.io/t/cant-connect-to-mongodb-for-unifi-network-application/8166 Ensure that your password does not use escape sequences. Maybe start with a simple username and password. Remove the volumes and start freshly. Otherwise, you may install an ARM64 or AARCH64 OS. Then the provided example should just work. |
So I went back to scratch on this and discovered the quotes in my init-mongo.js file were being stripped out for some reason. After fixing this, I could see the db connect and all seems to be working. Do I need to comment out the following line after initial setup? |
Perfect! Glad you got it working. You can comment out the volume mapping. However, this is not mandatory. Once the db is set up, it won't initialize again. |
Edit: It turns out I messed up the permissions of the I tried getting it up and running on my portainer setup but unfortunately it fails: version: "2.1"
services:
unifi-network-application:
image: lscr.io/linuxserver/unifi-network-application:latest
container_name: unifi-network-application
depends_on:
- unifi-db
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- MONGO_USER=unifi
- MONGO_PASS=password
- MONGO_HOST=unifi-db
- MONGO_PORT=27017
- MONGO_DBNAME=unifi-db
- MEM_LIMIT=3072 #optional
- MEM_STARTUP=3072 #optional
volumes:
- /mnt/tank/apps/unifi-network-application/config:/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
networks:
- unifi-bridge
restart: unless-stopped
unifi-db:
image: mongo:4.4
container_name: unifi-db
expose:
- 27017
volumes:
- /mnt/tank/apps/unifi-network-application/data:/data/db
- /mnt/tank/apps/unifi-network-application/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
networks:
- unifi-bridge
restart: unless-stopped
networks:
unifi-bridge:
driver: bridge db.getSiblingDB("unifi-db").createUser({user: "unifi", pwd: "password", roles: [{role: "dbOwner", db: "unifi-db"}]});
db.getSiblingDB("unifi-db_stat").createUser({user: "unifi", pwd: "password", roles: [{role: "dbOwner", db: "unifi-db_stat"}]}); These would be the container's error logs: Logs
At this point, I have a hard time understanding why the application is not able to log into the database... |
Remove your existing mongo-db volumes and recreate the stack. The database was likely provisioned with failures beforehand. Once the db exists, the init-mongo.js is ignored. |
It's worth noting that if something gets messed up with the database initialization and you're trying to recreate the containers you must clear out BOTH the mongodb data AND the unifi config folders. I initially didn't escape special characters in the password. I figured that part out pretty quickly and corrected it but only cleared out the mongodb data folder before recreating the containers thinking the unifi config would read an updated password specified in the compose file. That stymied me for a bit because the unifi app was still failing to authorize against the mongodb instance. I finally realized I should try clearing out everything before recreating the containers and that did the trick. |
What FOSS project is currently missing. Provide names and links.
Does an example docker-compose.yml exist?
It exists... but requires external mongodb and I don't have the required knowledge to do that. I would like a ready to use example please.
Here some links to pre-existing docker-compose examples:
It's only on the readme section of the repo.
Describe alternatives you've considered
I've searched for someone with an example but it's too new and there are none.
Additional context
I know it's not FOSS, but currently I'm using unifi-controller from linuxserver.io but they say, they are going to deprecate that image. I need to be ready when the time comes.
The text was updated successfully, but these errors were encountered: