Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

415
Visualizações
Docker MongoDB : UserNotFound

I am building a non-interactively configurable MongoDB image for Docker, with the current goal to be able to load auth users from a config file programmatically. My current problem is that albeit I can successfully add users to the database, they seem not to persist through the build process and as such my node container cannot successfully authenticate against the database.

Here's the main dockerfile for my mongodb instance:

FROM mongo:latest

#Installing Node
RUN apt-get update && \
    apt-get install -y curl && \
    curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
    apt-get install -y nodejs

#Setting Up Mongo
WORKDIR /var/www/smq
COPY ./docker/mongo-setup.js mongo-setup.js
COPY ./.config/mongo /var/www/.config/mongo
RUN if [ -e /var/www/.config/mongo/mongod.conf ] ; then cp /var/www/.config/mongo/mongod.conf /etc/mongod.conf ; fi
RUN mongod --port 27017 & node mongo-setup.js && mongod --shutdown

CMD ["mongod", "--auth", "--port", "27017"]

My setup also relies on docker-compose:

  mongodb:
    build:
      context: ../
      dockerfile: ./docker/mongodb-dockerfile
    container_name: mongo_container
    volumes:
     - /data/db

At step RUN mongod --port 27017 & node mongo-setup.js && mongod --shutdown, I get the print showing successful creation of users via the mongo shell. However when the two docker containers (mongo & node) are connected, I get the following error from the mongod :

2017-01-02T20:43:14.895+0000 I ACCESS [conn1] SCRAM-SHA-1 authentication failed for mydbuser on mydb from client 172.20.0.3:49762 ; UserNotFound: Could not find user mydbuser@mydb

How can I resolve this issue?

Ultimately, this is an effort to open-source my setup, hence you can reproduce the step by pulling this repository from github (currently the said setup is under /node-mongo on the branch node-mongo). Cheers!

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda