-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Mongo db #13
Comments
Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid. |
Working
and the
It could be part of readme or there could be a separate document for configurations cookbook or something. |
crosslinking: https://www.reddit.com/r/Ubiquiti/comments/16e8608/comment/k13f4yv/?utm_source=share&utm_medium=web2x&context=3 my compose-file is similar, but still on older version and with some unnecessary options ... |
We don't want to include a full mongodb compose example because people will just copy/paste it blindly and end up with versions they don't want and missing init files. |
Understood. Maybe add an explanation ... (?) |
We already have a fairly substantial section on the databse setup https://github.com/linuxserver/docker-unifi-network-application#setting-up-your-external-database. If you think there's specific stuff that needs to be included I'm happy to consider adding it. |
@thespad yes, the docs are quite good. thanks. |
Meanwhile me, who copied random snippets from the internet back and forth until it worked and ended up sharing it as "the solution". |
Like me, i do not know what mongo is and what it does. I like the containers to be mostly, add plug and play. For now i use the old image |
It's not a hill to die on, it's a preference based on past experience. Any time we are prescriptive in our instructions users blindly copy/paste them and then while things might work initially they run into problems later. You don't want to know how many users have all their data mounted into Half the issues so far have been people not reading the readme, initialising their database with junk data, and then not being able to connect the unifi app to it. There's nothing we can do if people are just going to skip over all of the warnings we've included. I'll have a conversation internally about how we can improve the readme instructions, but when you're dealing with a user base the breadth of ours it's rarely as straightforward as "just do x". As an aside, tag pulls are not a good metric. All of our images with additional tags beyond |
I will leave it up to you guys because you have more experience than me with these things. I am just coming in as a user trying to get what you built working. The current documentation is all over the place. It needs to be way more to the point and structured differently. Stop mixing discussion points with instructions on setting up a working environment.
An Application Setup area structured more like this with step by step instructions would be easier to follow:
db.getSiblingDB("MONGO_DBNAME").createUser({user: "MONGO_USER", pwd: "MONGO_PASS", roles: [{role: "readWrite", db: "MONGO_DBNAME"}]});
db.getSiblingDB("MONGO_DBNAME_stat").createUser({user: "MONGO_USER", pwd: "MONGO_PASS", roles: [{role: "readWrite", db: "MONGO_DBNAME_stat"}]});
version: "2.1"
services:
unifi-app:
image: lscr.io/linuxserver/unifi-network-application:latest
container_name: unifi-app
depends_on:
- unifi-db
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
- MONGO_USER=MONGO_USER
- MONGO_PASS=MONGO_PASS
- MONGO_HOST=unifi-db
- MONGO_PORT=27017
- MONGO_DBNAME=unifi
- MEM_LIMIT=1024 #optional
- MEM_STARTUP=1024 #optional
volumes:
- /unifi/app/config:/config
networks:
- unifi-network
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
unifi-db:
image: mongo:4.4.24
container_name: unifi-db
networks:
- unifi-network
ports:
- 27017:27017
volumes:
- /unifi/db/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
- /unifi/db/data:/data/db
- /unifi/db/config:/data/configdb
networks:
unifi-network:
driver: bridge
|
fun fact: same stack 2 times: one in my local environment, one at customer (that's the one in #15): in my stack the admin-user still is there and working. |
Thank you! I was able to successfully deploy using this without having to separately deal with a Mongo docker-compose. Suggestions: the harmful risk of someone using MONGO_USER and MONGO_PASS literally via cut&paste is lessened away if you make the mongo database inaccessible to outside the host's container environment. Instead of using "ports", let's use "expose". Another is to use the current working directory for init-mongo.js and other directories. Third is to not lock down to version 4.4.24, but pick up later mongo:4 versions. So, my working file, version: "2.1"
services:
unifi-app:
image: lscr.io/linuxserver/unifi-network-application:latest
container_name: unifi-app
depends_on:
- unifi-db
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
- MONGO_USER=MONGO_USER
- MONGO_PASS=MONGO_PASS
- MONGO_HOST=unifi-db
- MONGO_PORT=27017
- MONGO_DBNAME=unifi
- MEM_LIMIT=1024 #optional
- MEM_STARTUP=1024 #optional
volumes:
- ./unifi/app/config:/config
networks:
- unifi-network
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
unifi-db:
image: mongo:4
container_name: unifi-db
networks:
- unifi-network
expose:
- 27017
volumes:
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
- ./unifi/db/data:/data/db
- ./unifi/db/config:/data/configdb
networks:
unifi-network:
driver: bridge
|
thumbs up ... especially for the "expose" |
You shouldn't be exposing your db containers to the host network anyway, unless you have some specific need to access them from elsewhere on your network, or something running natively on the host. You should always use docker networking to keep that traffic isolated. |
@thespad this is the sort of discussion I was hoping for here. What are the best practices for this sort of configuration? You are obviously the expert here. You should try to share your knowledge via the documentation. How can this documentation leed users to the most robust outcome in the most efficient way possible? Right now it feels like people are being given just enough rope to hang themselves. On a side note if you have the bridge network setup between the containers(or the default network) and you don't need access outside of docker you don't need any |
The problem is that a lot of these discussions are around fundamental docker concepts and are well outside the scope of an individual image readme. We can't include first principles instruction in every repo, it's just not practical, there has to be an assumption that users either have, or are capable of obtaining, a basic understanding of how containers work and hang together. We know that a lot of people are just blindly copy/pasting (or, god help them, clicking the button in Unraid and crossing their fingers), but we just don't have the resources to design our support around that use case, we're a dozen or so volunteers managing 200+ images. |
I empathize with the struggles. My hope was to find an all-inclusive I found @natankeddem's comment here #13 (comment) especially helpful! Thank you! Perhaps this issue could be re-opened and reframed as a documentation request for a docker compose that includes the mongo service? |
I have read all the replys on this post and i still cant find a solution for my issue, i though ok im going to copy and paste exactly these configs and try them on, if they work ill modify them acordinly but no, it doesnt work for me, i keep getting a 404 page as soon as i get into https://myip:8443, what am i doing wrong? :-( my docker-compose.yml looks like this version: '3.8' unifi-app: unifi-db: networks: and this is the log im getting when i run docker logs
its telling me the user has not been found, but i created the init-mongo.js exactly as you did it on /unifi/db/init-mongo.js so i dont know whats going on Edit: i manage to make it work, but i had to login into mongo shell and insert both commands manually to create the users and db, imma figure it out whats going on with the script and then post a proper guide for future users :-) |
Aight, so this is a little guide for someone who has basic to no knoledge of how to use mongo or docker-container, im going to base it following the original guide on the nextcloud-aio github so here we go: Note: if you are migrating from the previous docker controller, just go to your controller - settings - backups and download ur backup file, then stop/delete your current controller and start this guide Step 1: Creating Mongo This file should be located where you assign your db folder on your docker-compose.yml or docker run command for this example im going to create a folder in
in there ill copy the content shown on the github example:
Now, we need to modify 3 fields according to what we want, the fields are
Notice he also changed the role dbOwner for readWrite, both options are fine, this just define the permisions the user have on the database So, save the file and now its time to create our docker compose file to fire up the mongo and the controller. Step 2: Create docker compose file for Mongo For this wer gonna use the sample on github and modify it to our needs and im going to call it mongo.yml
Note: i added the first part that was missing from the original github guide, for those who havent mess with docker-compose before. First of all we have to define the image, they say their docker support any version of mongo up to the latest, but the oficial support versions are the ones between 3.6 and 4.4, its up to you for which you wanna choose, but lets asumo wer going to pick the latest one oficially suported, we have to change Next we change the volumes to the ones we have created at the start of the example, in this case And now, our mongo.yml will look like this:
Step 3: Create docker compose file for the Unifi Controller For the last step, we need now to create another docker compose file, which im going to call unifi.yml and add the content on the github example:
And wer going to modify it acording to the information we put on our First thing we have to change is the user, for the one we used on
Note: if you dont have any other services running on your server, just leave ports as they are, or if u do, or you want to change the ports, lets asumo we want to use another http configuration port for lets say 8085, then we change So now we save the file and we should be ready to run our docker. Step 4: Running the controller and mongo Now we have everything ready to go, so we just execute the command:
Then docker will start downloading the images and once they are done they should run without issues, after it says they are running, give it about 30 secs as a first run before trying to access it, because the databases has to be generated and all the config files, so if you get a 404 page at first dont panic, give it a couple of secconds to refresh and should be good to go. The way to access for the first time should be going into the website https://:8443 asuming your ip is 10.0.0.2 should be https://10.0.0.2:8443. After that once your on the first page, setup your information and ull be done, also if your migrating from a previous controller you could click on the botton part on the option to import the backup and follow the instructions to finish. Optional: if you dont want to create diferent docker compose files, you can merge it all into one for example, like this will also be fine:
Lets asume we save that configo into a file called
Thats it, i hope this guide will help all of those in need to set this up without experience with mongo or docker-compose, i made this guide for internal hosting only, if you want to be able to access your controller from the internet, dont forget to open the ports on your router 👍 |
Doesn't work on a Pi4
|
For the next person having this issue. This is how I wrote the init script: #43 (comment) |
@rightsaidfred99, I have it running on on an Raspberry Pi 4 by pulling image version There are unofficial builds of more recent Mongodb for the Raspberry Pi here, but I haven't tested those.. |
Is this a new feature request?
Wanted change
Is it possible to get this image with the mongo stuff pre configured? I used the old image with ease. (synolgy nas)
I have trouble setting up the mongo db i have never used it
Reason for change
.
Proposed code change
.
The text was updated successfully, but these errors were encountered: