-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
[BUG] mongodb fails to load init-mongo.js and exits with code -3 #43
Comments
Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid. |
@matteo-g hinted me to this init script that worked for me. I am not sure why it works, if it is that only one user is created (and not the same user twice) or that the role is var user = "unifi";
var pwd = "password";
var data_db = "unifi";
var cfg_db = db + "_stat";
db.getSiblingDB(data_db).createUser(
{
user: user,
pwd: pwd,
roles: [
{
role: "dbOwner",
db: data_db
},
{
role: "dbOwner",
db: cfg_db
}
]
}
); NOTE: Maybe someone from the Mongo and JS community can make this cleaner? |
It was, obviously, my mistake. Make sure that the script is referenced through an absolute, host path, and with the proper permissions for mongo to open it. Make sure the script is not using commands that would not be available in the mongo version that is executing. Carefully check for errors in the mongo log. Mongo is a pain. |
Hi all, file permission (not sure it matters) docker-compose
Logs from DB: What kind of attribute is expected or this description missleading? Unfortunately I am completely new to docker which means I am not yet able to deep dive into it as I missing knowledge about possibilities to debug etc. Edit: So: Working conf
init file: mongo-init.js
|
This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions. |
I've gone through this and can start mongo with the provided init file and it works fine. As the mongo server is outside of what we publish, it may be best to work on this with their support. |
Dear @homerr : which init file are you referring? I'm struggling for weeks know trying to get this stuff working. NO WAY. The mongo-init.js is well mounted and accessible from within the container, but still have the [custom-init] No custom files found. This file is just not taken into account and of course my database isn't created and I can't go onward. I'm using Portainer as well. No idea why... Totally lost. I've never spent so much time trying a stack to get working just because of that stupid Mongo database... |
You didn't post any info on your compose so I can only guess. My guess is, you didn't follow the readme. |
You are right. If you get too worked up about a problem, you end up not thinking straight. version: '3.8'
services:
unifi_netapp_db:
image: mongo:6.0
container_name: unifi_netapp_db
hostname: unifi_netapp_db
volumes:
- /mnt/docker/unifi-netapp/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
- /mnt/docker/unifi-netapp/db-data/db:/data/db
restart: unless-stopped
networks:
- unifi_network
unifi_netapp_core:
image: lscr.io/linuxserver/unifi-network-application:latest
hostname: unifi_netapp_core
container_name: unifi_netapp_core
depends_on:
unifi_netapp_db:
condition: service_started
environment:
TZ: 'Europe/Paris'
MONGO_USER: mongo
MONGO_PASS: /run/secrets/mongo-password # Doesn't work...
#MONGO_PASS: "******" -> this case works fine
MONGO_HOST: unifi_netapp_db
MONGO_PORT: 27017
MONGO_DBNAME: unifi
secrets:
- mongo-password
volumes:
- /mnt/docker/unifi-netapp/core-data:/config
# ports:
# - 3478:3478/udp # Mandatory
# - 10001:10001/udp # Mandatory
# - 8080:8080 # Mandatory
# - 8443:8443 # GUI access being behind the reverse proxy
# - 8843:8843 # Optional
# - 8880:8880 # Optional
restart: unless-stopped
networks:
- proxy_network
- unifi_network
networks:
unifi_network:
driver: bridge
proxy_network:
external: true # proxy_network need to be created beforehand in Portainer interface
secrets:
mongo-password:
file: /mnt/docker/unifi-netapp/mongo_pass.txt If not working with secrets, I will try using environment variables... |
This issue is locked due to inactivity |
Is there an existing issue for this?
Current Behavior
There's an "init-mongo.js" file in a shared folder that the user that has launched "docker-compose.yml" file has rwx access to. When I open a bash terminal in the mongodb container, I can verify that the "init-mongo.js" file exists in the container with the following contents:
This file exists in the /docker-entrypoint-initdb.d directory inside the container with the following permissions:
However, the mongodb container reports that it couldn't load the init-mongo.js file:
This leads to both databases not being created. the database reports that it can't find user unifiuser because of that, when the unifi-network-application container tries to access the mongodb container:
docker-compose.yml:
init-mongo.js:
Expected Behavior
The mongodb container should load the init-mongo.js file and create the unifi and unifi_stat databases with it's corresponding users.
Steps To Reproduce
Environment
CPU architecture
x86-64
Docker creation
Container logs
The text was updated successfully, but these errors were encountered: