Skip to content

Instantly share code, notes, and snippets.

@linucksrox
Created November 21, 2023 18:49
Show Gist options
  • Save linucksrox/8d994f8b53070978a0c4842ac4964f07 to your computer and use it in GitHub Desktop.
Save linucksrox/8d994f8b53070978a0c4842ac4964f07 to your computer and use it in GitHub Desktop.
Unifi Network Application 8.0.7 with mongodb - docker-compose.yml
version: '3.7'
services:
unifi-db:
image: docker.io/mongo:latest
container_name: unifi-db
volumes:
- ./data:/data/db
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
restart: unless-stopped
unifi-network-application:
image: lscr.io/linuxserver/unifi-network-application:8.0.7
container_name: unifi-network-application
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- MONGO_USER=unifi
- MONGO_PASS=GETYOUROWNPASSWORD
- MONGO_HOST=unifi-db
- MONGO_PORT=27017
- MONGO_DBNAME=unifi
- MEM_LIMIT=1024 #optional
- MEM_STARTUP=1024 #optional
- MONGO_TLS= #optional
- MONGO_AUTHSOURCE= #optional
volumes:
- ./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
restart: unless-stopped
db.getSiblingDB("unifi").createUser({user: "unifi", pwd: "GETYOUROWNPASSWORD", roles: [{role: "dbOwner", db: "unifi"}]});
db.getSiblingDB("unifi_stat").createUser({user: "unifi", pwd: "GETYOUROWNPASSWORD", roles: [{role: "dbOwner", db: "unifi_stat"}]});
@leonidostrovski
Copy link

Thanks
Solve setup issue for me.
I made only the smallest improvement:
image: lscr.io/linuxserver/unifi-network-application:latest
instead
image: lscr.io/linuxserver/unifi-network-application:8.0.7

Thanks again

@HerrSenora
Copy link

If you set this up on a VM under Proxmox:
Makes sure you use: image: docker.io/mongo:7.0.15 as this is supported version´.
Also you need to set VM CPU to "Sandy Bridge" for AVX support (at least that worked for me)

Other than that this script is working fine. Many Thanks!

@vronp
Copy link

vronp commented Feb 26, 2025

First of all, thanks to all of you for the original post and the comments. This is going to save me a ton of time. I am getting an error involving port 1900 and I'm wondering how important it is. I tried 1901 and got the same error. I am doing this on a Synology NAS. The error: Error response from daemon: driver failed programming external connectivity on endpoint unifi-network-application (lots of letters and numbers): Error starting userland proxy: listen udp4 0.0.0.0:1900: bind: address already in use.

@linucksrox
Copy link
Author

@vronp it sounds like port 1900 isn't really needed for Unifi, so I'm not sure why I included that as optional. Your error message means something else on that system is already using port 1900 but since you don't need it for Unifi, just comment or remove that line from the docker compose file and try again.

https://community.ui.com/questions/Port-1900-udp-Abuse/d502b7b7-70a4-4396-8b5a-bee95993c48f

@vronp
Copy link

vronp commented Feb 28, 2025

Thanks very much for that. I commented out all the optional port assignments and I'm further along. Now, everything builds but mongo only runs for about a minute. I have no idea how to get at log output from mongo so I am going to need to do some research on this.

@linucksrox
Copy link
Author

linucksrox commented Feb 28, 2025

If you use docker compose up -d then you can immediately run docker compose logs -f. Alternatively, don't run in detached mode and you'll get logs directly from stdout with just docker compose up

For the mongo container, you need that init-mongo.js file in the same directory as the docker compose file for that bind mount on line 10. Without that it won't initialize the unifi database.

If you've already tried and failed, make sure you clear out the existing database in the data folder between retries. You need to create that empty folder if it doesn't exist already.

Share the logs and we can go from there.

Also docker ps is useful to check what the container is doing if you're not getting logs from it.

@vronp
Copy link

vronp commented Feb 28, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment