Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Bug: MongoDB container is reported ready before the server accepts connections

オープン
#1,122 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
docker, mongodb, python
領域
devops, testing

調査の方向性

Look at the MongoDbContainer class in testcontainers/mongodb.py to understand the current wait strategy. The fix involves updating the wait strategy to check for the 'Listening on' log entry with address '0.0.0.0' in JSON logs. Run the provided reproduction script to verify the bug and test the fix. Ensure the change works for MongoDB 4.4 and newer versions.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

When a root user is configured, which MongoDbContainer always does, the mongo image starts twice. A temporary server listening only on localhost creates the user and exits, then the real server starts. Both log "Waiting for connections", and the container's wait strategy matches the first one. So start() returns while no server is reachable from outside the container, and on a slow host the client times out before the real server is up.

I expected start() to return once the real server accepts connections. A line only the real server logs is the "Listening on" entry with address 0.0.0.0 (JSON logs, MongoDB 4.4 and newer), and waiting for r'"Listening on".*"address":"0\.0\.0\.0"' makes the snippet below pass.

To Reproduce

from testcontainers.mongodb import MongoDbContainer

# Limit the container to a tenth of a CPU, as a busy CI runner would.
with MongoDbContainer("mongo:7").with_kwargs(nano_cpus=100_000_000) as mongo:
    client = mongo.get_connection_client()
    print(client.admin.command("ping"))
pymongo.errors.ServerSelectionTimeoutError: localhost:50264: [Errno 54] Connection reset by peer (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s

It fails every time at this limit and passes with nano_cpus=1_000_000_000.

Runtime environment

macOS 26 (arm64), Docker 29.7.2, Python 3.14.0, testcontainers 4.15.0. The wait strategy on main is the same.

主要言語
Python
スター
2.3k
フォーク
386
平均マージ
4時間 40分
マージ済み PR(30日)
1

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

testcontainers/testcontainers-python のほかの issue

testcontainers/testcontainers-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。