Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

445
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda