Replies: 2 comments 2 replies
-
|
If you're using swarm, I'd suggest https://docs.docker.com/engine/swarm/secrets/ -- if you're not, I'd suggest considering it. 😄 I don't know if a |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
If you are running Using |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to setup the
mongodocker image in Docker Compose in such a way that:rootrole is created on theadmindatabase.readWriterole on another database is created.I want username, password and database to come from environment variables. This is proving to be impossible with the current
mongo:5.0.8image.This is the relevant part of my
docker-compose.yaml:The
MONGO_USER,MONGO_PASSandREAD_STORE_DBvalues are fetched from a.envfile.The
rootuser is successfully created by the docker-entrypoint.sh script, so this part of the setup works just fine.The problem comes when I try to setup my database user on
docker-entrypoint-initdb.d. I have the choice of using either a.jsor a.shfile in there to achieve this, as described in the Initializing a fresh instance section of the documentation.Problem is that neither work for my intent and purposes, here is why:
.jsfile - can not pass environment variables here, so I end up exposing the auth credentials on this file, which I want under revision control.shfile - file is executed by usermongodb, which causes 2 different problems:/home/mongodbhome directory does not exist, which causesmongoshto fail. It runs fine as userroot, or if I simply create the missing home directory.rootuser, but not themongodbuser.So basically I have my hands tied. If I run my script manually as
rootafter the container is up, everything works, but no way to get it to run properly by thedocker-entrypoint.shscript.Maybe I am missing something here, if that is the case, lets properly document how to achieve this. I have seen countless threads regarding this issue and people struggling with this simple user creation, which could be solved with a simple example on the documentation page.
Beta Was this translation helpful? Give feedback.
All reactions