petio-team / petio

Petio Request, Discover, Review
https://petio.tv
MIT License
251 stars 28 forks source link

Petio won't connect to mongo when deployed in docker - mongodb container crashing #370

Closed RedTedRedemption closed 3 years ago

RedTedRedemption commented 3 years ago

Petio is unable to connect to the mongodb container spun up by the docker-compose file provided in the Petio wiki

To Reproduce

  1. copy the sample docker-compose file provided by the guides in this repo and configure for the host system (volumes, ports,etc)
  2. exec docker-compose up -d
  3. begin petio setup and test the connection to mongodb
  4. connection times out

Expected Behavior The db test should succeed and allow the user to continue configuring the application

Logs and notes

Upon investigation, it appears that the mongodb container in the stack is crashing with the following error:

{"t":{"$date":"2021-04-26T06:26:50.586+00:00"},"s":"E", "c":"STORAGE", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db"}}

angrycuban13 commented 3 years ago

It sounds like you have permissions issues

RedTedRedemption commented 3 years ago

@angrycuban13 Docker can write to that dir. This issue occurs even when mongodb is not given any volumes to mount

angrycuban13 commented 3 years ago

The error is a permissions error. Docker might be able to write but the user that's running as Petio might not.

RedTedRedemption commented 3 years ago

@angrycuban13 Then it's an issue within the container - a bug. The container can write out to the host system (and it doesn't work even if it is configured to write only within the container) and I'm using the sample docker-compose file.

beyondmeat commented 3 years ago

You have to go to the db directory on the host and run chown with the uid,gid if the user that's in your docker-compose. This is actually an issue with the mongo dockerfile not handling permissions when running the container as a different user.

RedTedRedemption commented 3 years ago

what would that uuid/gid be? Also, docker-compose is running as root in my case. Docker runs as root on my system

angrycuban13 commented 3 years ago

Our example provides PUID/PGID variables if you're using an .env file with those variables filled in. If you're not using an .env file replace the PUID/PGID on the compose with that if your user.