Closed rathboma closed 4 years ago
This is the command it runs according to 'runlike':
docker run --name=stoic_ishizaka --hostname=727861e2332f --mac-address=02:42:ac:11:00:03 --env=POSTGRES_PASSWORD=example --env=POSTGRES_DB=banana --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/13/bin --env=GOSU_VERSION=1.12 --env=LANG=en_US.utf8 --env=PG_MAJOR=13 --env=PG_VERSION=13.0-1.pgdg100+1 --env=PGDATA=/var/lib/postgresql/data --volume=/var/lib/postgresql/data -p 0.0.0.0:33031:5432 -p 33031:5432 --label='org.testcontainers.session-id=ea1e07e55a3ca9878118f6c4ff33857a' --detach=true postgres:latest postgres
Thinking it may be because the container starts postgres twice - once to create the database, once to actually run it, and it gets hung up during that process somewhere?
Matthew
Hi @rathboma, does the Postgres image define a healthcheck? The wait strategies work like this:
HostPortWaitStrategy
(default): if we define an exposed port of 8000, testcontainers will wait until that port is boundLogWaitStrategy
: wait until the container outputs a given logHealthCheckWaitStrategy
: wait for the container's health check to succeed. If the image doesn't provide a health check, one can be provided with withHealthCheck({...})
Why not use the default wait strategy for postgres?
I tried that and still ran into problems. Let me do some double checking and double make sure I've not got a problem at my end.
(I also forgot to paste my custom wait strategy).
Hang tight I'll report back tomorrow (I'm probably doing something wrong)
Cool let me know, just FYI this works for me:
const { GenericContainer } = require("testcontainers");
(async () => {
const container = await new GenericContainer("postgres")
.withEnv("POSTGRES_USER", "test")
.withEnv("POSTGRES_PASSWORD", "test")
.withEnv("POSTGRES_DB", "postgres")
.withExposedPorts(5432)
.start();
await container.stop();
})();
Yeah I figured it out. I was using an old version of the pg library, but using the config syntax of the new version. It failed silently.
Sorry for the false bug report, but I very much appreciate the fast response. You helped a lot actually.
I'm creating a postgres container
But the health check never resolves and I cannot connect to it:
If I start a postgres container manually, it works and I can connect to it with my DB client:
Any thoughts?
I've tried:
I have a mysql test that works totally fine, so maybe this is something specific with how it runs the docker image?