Hello I am fairly new. I have been trying to link nextcloud to a separate database. I am trying to centralize all of my docker apps to have one database instead of spinning up a separate database for each app. I keep getting error internal server issue when I try to run the compose file.
This is the docker compose file.
in general exactly the opposite approach is used in Docker. Having multiple DB images running might consume little more RAM but it allows much better isolation and for this reason flexibility. Depending on the applications you might need run different DB server version which is hard(er) in centralized setup.
By default all containers from one docker compose can connect to each other using âinternalâ (default) network, which is silently created by docker compose. as described in GitHub - nextcloud/docker: â´ Docker image of Nextcloud
if you still want external/centralized DB define an âexternalâ network and connect both database and application container to this network. If DB and application are defined in different compose files you need to create an âexternalâ network and explicitly connect the service with this network:
Your config looks right for nextcloud service, but the other side is not shown.
Did you connect the database to the db network as well? Is there a reason why you configure db connection with an IP and not DNS? upon recreating DB container the IP will likely change.
If services do declare networks they are attached to, links should not override the network configuration and services not attached to a shared network should not be able to communicate.
I did connect the database to the same network. I wasnât really sure how to link an external service without directly defining it. I figured it would be fine since I set up the databases to have the port open. I also could reach them with adminer. Here is the database stack I made.
services:
mariadb:
image: mariadb
container_name: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
privileged: true
environment:
MARIADB_USER: xxx
MARIADB_PASSWORD: xxx
MARIADB_DATABASE: xxx
PUID: xxx
PGID: xxx
ports:
- "3306:3306"
volumes:
- /database/MariaDB:/var/lib/mysql:rw
networks:
- db
postgresdb:
image: postgres
container_name: postgres
privileged: true
environment:
POSTGRES_USER: xxx
POSTGRES_PASSWORD: xxx
POSTGRES_DB: xxx
PUID: xxx
PGID: xxx
ports:
- "5432:5432"
volumes:
- /database/PostgresDB:/var/lib/postgresql/data:rw
networks:
- db
redisdb:
image: redis
container_name: redis
restart: always
command: redis-server --save 20 1 --loglevel warning
privileged: true
ports:
- "6379:6379"
volumes:
- /database/RedisDB:/data:rw
networks:
- db
adminerdb:
container_name: adminer
image: adminer
restart: always
ports:
- "8080:8080"
networks:
- db
networks:
db:
external: true```
I also tried to use the `links:` but I got a service not defined in the compose file error and when i tried to use `external-links:` I got service unsupported. I wanted to reduce the system resources so that I can run multiple game servers on the machine more comfortably. Is there a resource on how to manage databases for apps and best practices? I appreciate the help.
form this configuration you should see all the container and their IP addresses within db network if you run docker inspect network db⌠all the containers connected to this network are expected to reach each other using their service names e.g. âpostgresâ or âmariadbâ no need to use IP addresses.