I have a postgres container running as host
network_mode and a Nextcloud container running on default (bridged) network with port 8080:80
.
How can I link the containers so that Nextcloud can access postgres? I've tried adding this to my docker-compose.yml
, but it doesn't seem to work.
services:
nextcloud:
external_links:
- "postgres:postgres"
Command I use to run postgres:
docker run --name postgres --net host --restart always postgres
When I do that, it gives me this error
Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7] could not translate host name "postgres" to address: Name or service not known
Alternate Option: How can I define the port I want nextcloud to listen on, so I can use it on the host network?