I am not quite sure how to setup networks in docker-compose.yml
for Postgres and Adminer. All examples I can find are about Postgres and Adminer in same docker-compose.yml
meaning separate Adminer for each app, and I dont want that, I want single Adminer for entire VPS instance.
I have another docker-compose.yml
with Traefik and Portainer, and I want to add Adminer in that file but I am not sure how to set up networks.
I am aware that with Adminer I can connect to any database with IP, but since this is same VPS I guess Adminer can read hostname trough Docker network.
I have proxy
external network that Traefik uses to discover containers. I assume I can’t have Adminer and Postgres on same internal network since they aren’t defined in same container.
Note that I need Postgres to be available for connections from external servers as I will use it’s connection string in Github actions for building the app container, Next.js app needs to read data to prerender pages.
Do you have advice or example how to setup networks? Here is my incomplete setup so far:
docker-compose.yml for reverse proxy in which I want to add Adminer
services:
traefik:
image: "traefik:v2.5.6"
networks:
- proxy
...
adminer:
image: adminer:4.8.1-standalone
networks:
- proxy
labels:
- "traefik.http.routers.adminer.rule=Host(`adminer.${DOMAIN}`)"
- "traefik.http.services.adminer.loadbalancer.server.port=8080"
networks:
proxy:
external: true
docker-compose.yml for my app, Adminer should connect to this Postgres container
app:
depends_on:
- postgres-db-prod
...
networks:
- proxy
- internal
postgres-db-prod:
image: postgres:14-alpine
container_name: postgres-db-prod
restart: unless-stopped
ports:
- 5432:5432
volumes:
- ./prisma/pg-data:/var/lib/postgresql/data
env_file:
- .env.local
labels:
- 'traefik.enable=false'
networks:
- proxy
- internal
networks:
proxy:
external: true
internal:
external: false
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!