Replies: 2 comments
-
Make the following changes to the docker compose file
x-postgres-common:
&postgres-common
image: postgres:17-alpine
user: postgres
restart: always
healthcheck:
test: 'pg_isready -U user --dbname=postgres'
interval: 10s
timeout: 5s
retries: 5
services:
postgres-primary:
<<: *postgres-common
ports:
- 5432
environment:
POSTGRES_USER: user
POSTGRES_DB: postgres
POSTGRES_PASSWORD: password
POSTGRES_HOST_AUTH_METHOD: "scram-sha-256\nhost replication all 0.0.0.0/0 md5"
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
command: |
postgres
-c wal_level=replica
-c hot_standby=on
-c max_wal_senders=10
-c max_replication_slots=10
-c hot_standby_feedback=on
volumes:
- ./00_init.sql:/docker-entrypoint-initdb.d/00_init.sql
postgres-standby:
<<: *postgres-common
ports:
- 5432
environment:
PGUSER: replicator
PGPASSWORD: replicator_password
command: |
bash -c "
until pg_basebackup --pgdata=/var/lib/postgresql/data -R --slot=replication_slot --host=postgres-primary --port=5432
do
echo 'Waiting for primary to connect...'
sleep 1s
done
echo 'Backup done, starting replica...'
chmod 0700 /var/lib/postgresql/data
postgres
"
depends_on:
- postgres-primary Then, add wait strategy for each service environment = new ComposeContainer(dockerComposeFile.getFile())
.withExposedService("postgres-primary", 5432, Wait.forLogMessage(".*database system is ready to accept connections.*", 2))
.withExposedService("postgres-standby", 5432, Wait.forLogMessage(".*database system is ready to accept read-only connections.*", 1)); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thx a lot @eddumelendez it's working |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Module
PostgreSQL
Testcontainers version
1.19.7
Using the latest Testcontainers version?
Yes
Host OS
MacOs 15.4.1
Host Arch
x86
Docker version
version Client: Docker Engine - Community Version: 28.0.1 API version: 1.47 (downgraded from 1.48) Go version: go1.24.0 Git commit: 068a01ea94 Built: Tue Feb 25 17:52:55 2025 OS/Arch: darwin/arm64 Context: default Server: Docker Engine - Community Engine: Version: 27.4.0 API version: 1.47 (minimum version 1.24) Go version: go1.22.10 Git commit: 92a8393 Built: Sat Dec 7 10:39:01 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.7.24 GitCommit: 88bf19b2105c8b17560993bee28a01ddc2f97182 runc: Version: 1.2.2 GitCommit: v1.2.2-0-g7cb3632 docker-init: Version: 0.19.0 GitCommit: de40ad0
What happened?
Running this test : https://github.com/Bzil/repoduce-error-testcontainer
And got a
Container startup failed for image docker:24.0.2
Relevant log output
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions