Failed container starts aren't always reported
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- c, docker, postgresql
- Lĩnh vực
- devops, testing-qa
Hướng nghiên cứu
Start with tc_container_run() and the generic-container-test changes described in the issue, then inspect the PostgreSQL container demo. Trace how immediate container termination and the error value are handled, including whether container logs are collected. Done means failed starts reliably fail the demo and expose useful diagnostics instead of reporting a passing test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I discovered this while working on a 'postgresql container demo' - and before discovering the outstanding PR related to PostgreSQL. That PR may have fixed this specific issue but I'm sure similar issues abound and that possibility should be documented.
TLDR
- fix
tc_container_run()so theerrorvalue is actually used - in demos add check that the application hasn't already exited
- in demos add container logs in addition to docker daemon logs
- remind, remind, remind everyone that it's critical to verify results. Things will slip through for a long time.
Details
The problem is that the official PostgreSQL images require a password to be provided via an environment variable. Any attempt to run one of these images without one immediately fails.
Sample output:
bgiles@eris:$ docker run postgres:18
Error: Database is uninitialized and superuser password is not specified.
You must specify POSTGRES_PASSWORD to a non-empty value for the
superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
connections without a password. This is *not* recommended.
See PostgreSQL documentation about "trust":
https://www.postgresql.org/docs/current/auth-trust.html
However when I made a quick tweak to generic-container-test to replace the image name and remove the wait I see no indication of a problem. Nothing in the logs, the test is reported as passing.
41 │
42 │ 2/5 Testing: postgresql_container_demo
43 │ 2/5 Test: postgresql_container_demo
44 │ Command: "/home/bgiles/code/testcontainers-native/build/demo/postgresql-container/postgresql-container-demo.out"
45 │ Directory: /home/bgiles/code/testcontainers-native/build/demo/postgresql-container
46 │ "postgresql_container_demo" start time: Feb 02 12:51 MST
47 │ Output:
48 │ ----------------------------------------------------------
49 │ Creating new container: postgres:18-alpine
50 │ RequestID: 0
51 │ Testcontainers properties file has been found: /home/bgiles/.testcontainers.properties
52 │ 2026/02/02 12:51:20 github.com/testcontainers/testcontainers-go - Connected to docker:
53 │ Server Version: 29.2.0
54 │ API Version: 1.43
55 │ Operating System: Ubuntu 24.04.3 LTS
56 │ Total Memory: 64221 MB
57 │ 2026/02/02 12:51:20 🐳 Creating container for image docker.io/testcontainers/ryuk:0.5.1
58 │ 2026/02/02 12:51:20 ✅ Container created: cbf1b3aefe60
59 │ 2026/02/02 12:51:20 🐳 Starting container: cbf1b3aefe60
60 │ 2026/02/02 12:51:20 ✅ Container started: cbf1b3aefe60
61 │ 2026/02/02 12:51:20 🚧 Waiting for container id cbf1b3aefe60 image: docker.io/testcontainers/ryuk:0.5.1. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
62 │ 2026/02/02 12:51:20 🐳 Creating container for image postgres:18-alpine
63 │ 2026/02/02 12:51:20 ✅ Container created: 84c6797e69bb
64 │ 2026/02/02 12:51:20 🐳 Starting container: 84c6797e69bb
65 │ 2026/02/02 12:51:20 ✅ Container started: 84c6797e69bb
66 │ ContainerId: 0:
67 │ 2026/02/02 12:51:20 🐳 Terminating container: 84c6797e69bb
68 │ 2026/02/02 12:51:21 🚫 Container terminated: 84c6797e69bb
69 │ Terminating container: 0
70 │ <end of output>
71 │ Test time = 0.91 sec
72 │ ----------------------------------------------------------
73 │ Test Passed.
74 │ "postgresql_container_demo" end time: Feb 02 12:51 MST
75 │ "postgresql_container_demo" time elapsed: 00:00:00
76 │ ----------------------------------------------------------
(I added a few extra print statements and fflush() so I can see those print statements at the right point.)
This may be something as simple as fixing
char* error = "";
int containerId = tc_container_run(requestId, error);
if (containerId == -1) {
printf("Failed to run the container: %s\n", error);
return -1;
}
since C doesn't have pass-by-reference. and 'error' will never change. The Go library may not even consider the immediate termination of the application an error.
However we should have the ability to determine if the application has already terminated before we wait for the server to start.
- Ngôn ngữ chính
- C
- Star
- 58
- Fork
- 14
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của testcontainers/testcontainers-native
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
testcontainers/testcontainers-native#70 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
documentation help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Add Ollama ModuleĐang mởenhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
Tất cả issue của testcontainers/testcontainers-native
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
schrodinger/pymol-open-source#532 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
facebookexperimental/hermit#347 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
CTSRD-CHERI/cheribsd#2769 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Add unit tests for SafetyStateĐang mởgood first issue not started
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
CU-Robotics/firmware#257 ·
-
valkey-benchmark got `WARNING: Could not fetch server CONFIG` when running against the proxyĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
valkey-io/valkey-proxy#45 ·
Maintainer thường phản hồi trong vòng 1 ngày