I want to setup wikijs together with postgres using docker-compose. It works, but only when I use network_mode host. When I want to setuptheir own network, wikijs is not able to connect to postgres, giving me the following error:
Database Connection Error: ECONNREFUSED 127.0.0.1:5432
This is my docker-compose.yml:
version: "3.3"
services:
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: wiki
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
POSTGRES_USER: wikijs
restart: unless-stopped
volumes:
- /opt/docker/docker-volumes/postgresql/data:/var/lib/postgresql/data
secrets:
- db_password
wiki:
image: ghcr.io/requarks/wiki:2
depends_on:
- db
environment:
DB_TYPE: postgres
DB_HOST: db
DB_PORT: 5432
DB_USER: wikijs
DB_PASS_FILE: /run/secrets/db_password
DB_NAME: wiki
CONFIG_FILE: /wiki/config/config.yml
restart: unless-stopped
ports:
- "4501:4500"
# Mount config file into container
volumes:
- ./config.yml:/wiki/config/config.yml
secrets:
- db_password
secrets:
db_password:
file: ./secrets/db_password.txt
volumes:
db-data:
Please note that I am using ports 4501:4500 because I have a running wikijs instance on 4500 already, with the before-mentioned network_mode host.