testcontainers / testcontainers/testcontainers-python

Bug: Running Container with_network makes get_exposed_port unreliable

Đang mở
#633 8 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

🤝 contributions are welcome 🛟 help wanted
Ngôn ngữ chính
Python
Star
2.3k
Fork
386
Merge trung bình
4 giờ 40 phút
Pull request đã merge (30 ngày)
1

Mô tả

Describe the bug

Hello!

I have a case where I want to run several containers inside a specific docker network environment.
However when attaching a container to a network it seems that port forwarding is not attached to the new network - making the overall experience unstable(not able to get postgres URL, few containers like Minio do healthcheck that hangs etc)

It seems like this is not always the case however. Roughly 30% of the times the ports are actually forwarded and it succeeded. However most of the time it fails: resulting in hanging operations etc.

To Reproduce

Given a case as below. Keep in mind that sometimes it does work. Most of the time it won't.
Result will be that get_exposed_port operation hangs

from testcontainers.postgres import PostgresContainer
from testcontainers.core.network import Network

with Network() as network:
    c = PostgresContainer("postgres:13.3-alpine")
    c.with_network(network)
    c.start()
    print("Port: ", c.get_exposed_port(5432))
    c.stop()

Runtime environment

Provide a summary of your runtime environment. Which operating system, python version, and docker version are you using? What is the version of testcontainers-python you are using? You can run the following commands to get the relevant information.

# Get the operating system information (on a unix os).
$ uname -a
Darwin Henriks-MBP-2.fritz.box 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103 arm64
# Get the python version.
$ python --version
Python 3.12.3
# Get the docker version and other docker information.
$ docker info
Client:
 Version:           26.1.4
 API version:       1.45
 Go version:        go1.21.11
 Git commit:        5650f9b
 Built:             Wed Jun  5 11:26:02 2024
 OS/Arch:           darwin/arm64
 Context:           default

Server: Docker Desktop 4.31.0 (153195)
 Engine:
  Version:          26.1.4
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.11
  Git commit:       de5c9cf
  Built:            Wed Jun  5 11:29:12 2024
  OS/Arch:          linux/arm64
  Experimental:     true
 containerd:
  Version:          1.6.33
  GitCommit:        d2d58213f83a351ca8f528a95fbd145f5654e957
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
# Get all python packages.
$ pip freeze
docker==7.1.0
testcontainers==4.6.0

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với các entry point with_network, start và get_exposed_port, đồng thời tái hiện ví dụ PostgresContainer được cung cấp. Theo dõi cách việc gắn vào mạng Docker và ánh xạ cổng được xử lý, sau đó xác minh rằng các lần chạy lặp lại luôn trả về cổng được expose mà không bị treo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
docker, postgresql, python
Lĩnh vực
devops, infrastructure, testing-qa
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
32/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.