Closed sazzer closed 2 years ago
Just to rule it out, I've just deleted all containers and images and tried again, with the same results.
It turns out it's a configuration error, but the output is very unhelpful.
The problem was that I need to provide some environment params for the container to start, and without them it fails. This works:
req := testcontainers.ContainerRequest{
Image: "postgres:12.4-alpine",
Env: map[string]string{
"POSTGRES_DB": "test",
"POSTGRES_USER": "test",
"POSTGRES_PASSWORD": "test",
},
ExposedPorts: []string{"5432/tcp"},
WaitingFor: wait.ForListeningPort("5432/tcp"),
}
However, I only worked that out by actually putting a sleep after the startup and then looking at the container logs with docker logs -f
. The output from testcontainers wasn't helpful at all :(
See #252 .
I did not find this issue as I was searching for the error message.
Hi, I'm checking the postgres docs for their Docker image and they mention the need of explicitly setting the POSTGRES_PASSWORD
variable to make it:
POSTGRES_PASSWORD
This environment variable is required for you to use the PostgreSQL image. It must not be empty or undefined. This environment variable sets the superuser password for PostgreSQL. The default superuser is defined by the POSTGRES_USER environment variable.
I'm closing this issue as it's not related to testcontainers-go. Thanks!
Describe the bug Using Testcontainers to start a Postgres container seems to not work at all. The container fails to start correctly.
To Reproduce
Output from this is:
Expected behavior The container to start correctly.
docker info
Additional context Other containers seem to work fine. I've tested the exact code above with
nginx
andredis
successfully.This container itself also works fine when running normally, via
docker run
ordocker-compose
. And I've done this recently with the Rust Testcontainers with no problems.I've had this exact error with all of the
postgres
containers I've tried - different versions, alpine or buster, etc.This is running on go 1.15.2, but also reproduces on 1.14.7.