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

440
Visualizações
Unable to set volume for mongodb logs in docker container

My docker mongo images

REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
mongo        latest    f03be0dc25f8   2 days ago   448MB

My container command

docker run -it --name c1_mongo -p 37017:27017 -v /var/mongo/data/c1_mongo:/data/db -v /var/mongo/config/c1_mongo/mongod.conf.orig:/etc/mongod.conf.orig -v /var/mongo/logs/c1_mongo:/var/log/mongodb mongo -f /etc/mongod.conf.orig

The error I am getting

{"t":{"$date":"2021-03-29T11:00:02.967Z"},"s":"F",  "c":"CONTROL",  "id":20574,   "ctx":"main","msg":"Error during global initialization","attr":{"error":{"code":38,"codeName":"FileNotOpen","errmsg":"Failed to open /var/log/mongodb/mongod.log"}}}
  1. I have successfully set the volume for my data directory inside the container to my host
  2. I have successfully set the volume for my config file inside the container to my host
  3. Setting the volume for the log is failing.

When I change my config file in the host and run the container so my all changes get reflected in my config file in the container. And data in my container's /data/db directory is being synced to my respective folder in the host.

Just like my data if being stored in my host. I want my logs to be stored on my host as well.

Note: volume mapping showing the directories of both host and container.

Please Help!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This issue can be resolved using the following steps.

  1. Run the container without mounting the volume which is causing the issue.
  2. Go into container bash and check the folder permission on which you are facing issue in my case it is /var/log/mongodb
  3. Now check the owner of the folder.
  4. run "cat passwd" in container shell and find that owner you found in last step and note the id against it could be(999 or 1000 etc).
  5. Now exit the container, stop it, remove it.
  6. Now on your host log path which in my case is /var/mongo/data/c1_mongo
  7. Change the owner of c1_mongo folder to, "chown -R 999:999 c1_mongo" (999 is the id you found in step 4)
  8. Now run your container again.
over 4 years ago · Santiago Trujillo Relatório
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