Coder Social home page Coder Social logo

Comments (16)

l4rm4nd avatar l4rm4nd commented on May 14, 2024 1

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:

---
version: "2.1"
services:
  unifi-network-application:
    image: lscr.io/linuxserver/unifi-network-application:latest
    container_name: unifi-network-application
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - MONGO_USER=unifi
      - MONGO_PASS=unifi
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27017
      - MONGO_DBNAME=unifi-db
      - MEM_LIMIT=1024 #optional
      - MEM_STARTUP=1024 #optional
    volumes:
      - ${DOCKER_VOLUME_STORAGE:-/mnt/docker-volumes}/unifi-network-application/config:/config
    depends_on:
      - unifi-db
    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
    container_name: unifi-network-application-mongodb
    restart: unless-stopped
    expose:
      - 27017
    environment:
      - MONGO_INITDB_DATABASE=unifi-db
    volumes:
      - ${DOCKER_VOLUME_STORAGE:-/mnt/docker-volumes}/unifi-network-application/mongodb_data:/data/db
      - ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro

Note that you are mounting a file named init-mongo.js into the mongo db container. This file is necessary to initialize the mongo database (see https://hub.docker.com/_/mongo/ at "Initializing a fresh instance"). It basically defines the database name and user credentials for the unifi-network-application container.

The file contains the following content:

db.getSiblingDB("unifi-db").createUser({user: "unifi", pwd: "unifi", roles: [{role: "readWrite", db: "unifi-db"}]});
db.getSiblingDB("unifi-db_stat").createUser({user: "unifi", pwd: "unifi", roles: [{role: "readWrite", db: "unifi-db_stat"}]});

These parameters are also referenced in the docker-compose.yml file above. So either leave as is or adjust everywhere accordingly. May have a try and give feedback whether my example works.

As long as the given example is unconfirmed, I will not include it to this repository.

from compose-examples.

Ciberbago avatar Ciberbago commented on May 14, 2024 1

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 :)

from compose-examples.

l4rm4nd avatar l4rm4nd commented on May 14, 2024

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

from compose-examples.

rgars avatar rgars commented on May 14, 2024

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?

from compose-examples.

l4rm4nd avatar l4rm4nd commented on May 14, 2024

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.

from compose-examples.

rgars avatar rgars commented on May 14, 2024

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:-
t={"$date":"2023-11-21T17:07:31.694+00:00"} s=I c=ACCESS id=20249 ctx=conn10169 msg=Authentication failed attr={"mechanism":"SCRAM-SHA-256","speculative":true,"principalName":"unifi","authenticationDatabase":"unifi-db","remote":"172.18.0.3:37178","extraInfo":{},"error":"UserNotFound: Could not find user "unifi" for db "unifi-db""}

from compose-examples.

l4rm4nd avatar l4rm4nd commented on May 14, 2024

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:-
t={"$date":"2023-11-21T17:07:31.694+00:00"} s=I c=ACCESS id=20249 ctx=conn10169 msg=Authentication failed attr={"mechanism":"SCRAM-SHA-256","speculative":true,"principalName":"unifi","authenticationDatabase":"unifi-db","remote":"172.18.0.3:37178","extraInfo":{},"error":"UserNotFound: Could not find user "unifi" for db "unifi-db""}

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.

from compose-examples.

rightsaidfred99 avatar rightsaidfred99 commented on May 14, 2024

Anyone know how to get it to work on a pi? I've modified it

`---
version: "2.1"
services:
  unifi-network-application:
    image: lscr.io/linuxserver/unifi-network-application:arm64v8-latest
    container_name: unifi-network-application
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - MONGO_USER=unifi
      - MONGO_PASS=unifi
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27017
      - MONGO_DBNAME=unifi-db

    volumes:
      - /home/pi/docker/unifinetwork/app:/config
    depends_on:
      - unifi-db
    ports:
      - 8443:8443
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
    restart: unless-stopped

  unifi-db:
    image: mongo:4.4
    platform: linux/arm64
    container_name: unifi-network-application-mongodb
    restart: unless-stopped
    expose:
      - 27017
    environment:
      - MONGO_INITDB_DATABASE=unifi-db
    volumes:
      - /home/pi/docker/unifinetwork/db/data:/data/db
      - /home/pi/docker/unifinetwork/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro`

it runs, but it restarts in docker without a log or error message. :(

from compose-examples.

l4rm4nd avatar l4rm4nd commented on May 14, 2024

Anyone know how to get it to work on a pi? I've modified it

`---
version: "2.1"
services:
  unifi-network-application:
    image: lscr.io/linuxserver/unifi-network-application:arm64v8-latest
    container_name: unifi-network-application
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - MONGO_USER=unifi
      - MONGO_PASS=unifi
      - MONGO_HOST=unifi-db
      - MONGO_PORT=27017
      - MONGO_DBNAME=unifi-db

    volumes:
      - /home/pi/docker/unifinetwork/app:/config
    depends_on:
      - unifi-db
    ports:
      - 8443:8443
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
    restart: unless-stopped

  unifi-db:
    image: mongo:4.4
    platform: linux/arm64
    container_name: unifi-network-application-mongodb
    restart: unless-stopped
    expose:
      - 27017
    environment:
      - MONGO_INITDB_DATABASE=unifi-db
    volumes:
      - /home/pi/docker/unifinetwork/db/data:/data/db
      - /home/pi/docker/unifinetwork/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro`

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 webhippie/mongodb:latest-arm32v7.

https://forums.docker.com/t/mongo-db-raspberry-pi4/138908/2

from compose-examples.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.