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"}}}
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!
This issue can be resolved using the following steps.
- Run the container without mounting the volume which is causing the issue.
- Go into container bash and check the folder permission on which you are facing issue in my case it is /var/log/mongodb
- Now check the owner of the folder.
- 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).
- Now exit the container, stop it, remove it.
- Now on your host log path which in my case is /var/mongo/data/c1_mongo
- Change the owner of c1_mongo folder to, "chown -R 999:999 c1_mongo" (999 is the id you found in step 4)
- Now run your container again.