Nextcloud and external Postgres docker?


I’m running Docker on Ubuntu 18 VPS:

Since I already have a Postgres Docker running and accepting internal connection on port 5432, what do I have to add to docker-compose so that Nextcloud uses the already running postgres docker?
Can you point me to a tutorial or some documentation.
Thank you for your help


That should be fine. You just need to configure Nextcloud to use it according to standard installation procedure. Make sure you don’t use use a loopback IP as Docker containers don’t support addressing a port on the host that way.

do you mean I just have to put nexcloud pfm and redis on docker-compose and then, at the first run, specify DB address?

Sure. As long as Nextcloud can make the connection and you give it a good db login, it should work the same.

You may not need to add anything to the compose file if you already have a host port exposed for it. Just use the host interface IP (not 127.x.x.x) or hostname if appropriate and the port.

1 Like

I will add though, I’m not sure if it really takes any appreciable additional resources to run two databases in one Postgres versus running two instances of Postgres. If you add it’s own instance to the compose file, you don’t have to open the port to Postgres at all, which is a security improvement.