Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

439
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!