MongoDB docker error: Failed to open /var/log/mongodb/mongod.log

Viewed 4233

I am trying to run a docker instance and keep coming across this server. Here is what I get after trying to setup the instance:

Starting instance ... done
Attaching to instance
instance   | {"t":{"$date":"2020-12-08T14:06:42.033Z"},"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"}}}
instance exited with code 1

The file permissions are:

$ ls -l /var/log/mongodb/mongod.log
-rwxr-xr-x 1 mongodb mongodb 0 Dec  8 19:32 /var/log/mongodb/mongod.log

What else I've tried:

  1. Shutting down and removing all containers and removing the build-cache
  2. Removing all .sock files from /var/lib/mongodb
  3. uninstalling and reinstalling docker.
  4. Checking if the ports on my .conf file are unoccupied.
  5. Adding user mongodb as owner and group to both the lib and log mongodb folders.

I am not sure anymore where this issue is coming from. Would like to have some alternate solutions to this.

1 Answers

I had the same issue. I think the permission could be wrong for the folder. Try setting the permission 777 for log and data

Related