testcontainers / testcontainers/testcontainers-python

docker.errors.NotFound: 404 Client Error when launching MongoDB on Ubuntu 22.04 running in WSL2.

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

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

👀 requires attention 🔀 requires triage
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

...expected it to run?

To Reproduce

Provide a self-contained code snippet that illustrates the bug or unexpected behavior. Ideally, send a Pull Request to illustrate with a test that illustrates the problem.

from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorCollection
from testcontainers.core.container import DockerContainer
from testcontainers.mongodb import MongoDbContainer
from testcontainers.core.waiting_utils import wait_for

async def test_db():
    with DockerContainer("mongodb/mongodb-community-server:latest").with_bind_ports(27017, 27017) as mongo_container:
        def connect():
            return AsyncIOMotorClient("mongodb://{}:{}".format(mongo_container.get_container_host_ip(),
                                                           mongo_container.get_exposed_port(27017)))


    db = wait_for(connect).primer
    result = db["restaurants"].insert_one(
        {
            "address": {
                "street": "2 Avenue",
                "zipcode": "10075",
                "building": "1480",
                "coord": [-73.9557413, 40.7720266]
            },
            "borough": "Manhattan",
            "cuisine": "Italian",
            "name": "Vella",
            "restaurant_id": "41704620"
        }
    )
    cursor = db.restaurants.find({"borough": "Manhattan"})
    for document in await cursor.to_list(1000):
        print(document)

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
Linux DESKTOP-GJIUB03 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# Get the python version.
$ python --version
Python 3.10.6
# Get the docker version and other docker information.
$ docker info
https://pastebin.com/raw/5meC1tZJ
# Get all python packages.
$ pip freeze
https://pastebin.com/raw/zJQfnQkb

Latest version of testcontainers-python and MongoDB.

Full traceback when I run the snippet: https://pastebin.com/raw/3TvwYiLa (warn me if I doxxed myself in somewhere)

I can launch this container inside WSL, so Docker is working. Weird.

image

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 bằng cách tái hiện đoạn mã Python được cung cấp bằng DockerContainer hoặc MongoDbContainer trên Ubuntu 22.04 trong WSL2. Xem lại traceback được liên kết, thông tin Docker và các phiên bản gói để xác định tại sao việc khởi chạy MongoDB trả về 404. Công việc được xem là hoàn tất khi nguyên nhân đã được ghi lại và bài kiểm thử MongoDB chạy thành công trong môi trường được báo cáo.

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, mongodb, python
Lĩnh vực
databases, devops, 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
Cần làm rõ
Mức phù hợp với người mới
25/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.