Hi Docker Peeps,
I have a curious question.
I created a container using docker compose using the two files.
ztm_postgre.yaml
version: '3.8'
services:
ztm_postgre:
image: postgres:14
ports:
- 5432:5432
environment:
- POSTGRES_USER=ztm_user
- POSTGRES_PASSWORD=ztm_password
- POSTGRES_DB=ztm_db
volumes:
- postgre_db_data:/var/lib/postgresql/data
volumes:
postgre_db_data:
driver: local
ztm_postgre-copy.yaml
version: '3.8'
services:
ztm_postgre2:
image: postgres:14
ports:
- 5433:5432
environment:
- POSTGRES_USER=ztm_user
- POSTGRES_PASSWORD=ztm_password
- POSTGRES_DB=ztm_db
volumes:
- postgre_db_data:/var/lib/postgresql/data
volumes:
postgre_db_data:
driver: local
Both containers are poniting to the “/var/lib/docker/volumes/smartbrain-fe_postgre_db_data/_data” on the running host.
When I connect to both localhost:5432 and localhost:5433, both instance do not see each other changes. Why is that?
The contents on the host directory file do not show any duplicate files that would indicate that the other container is looking at a different file.
lpt-linuxmint01:~$ sudo ls /var/lib/docker/volumes/smartbrain-fe_postgre_db_data/_data
base pg_commit_ts pg_hba.conf pg_logical pg_notify pg_serial pg_stat pg_subtrans pg_twophase pg_wal postgresql.auto.conf postmaster.opts
global pg_dynshmem pg_ident.conf pg_multixact pg_replslot pg_snapshots pg_stat_tmp pg_tblspc PG_VERSION pg_xact postgresql.conf postmaster.pid
Why are both containers not seeing the same database?