testcontainers / testcontainers/testcontainers-python

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

未关闭
#323 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

👀 requires attention 🔀 requires triage
主要语言
Python
星标
2.3k
派生
386
平均合并
4 小时 40 分钟
30 天内合并 PR
1

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在 WSL2 上的 Ubuntu 22.04 中使用 DockerContainer 或 MongoDbContainer 重现提供的 Python 代码片段。查看链接的 traceback、Docker 信息和软件包版本,以确定为什么启动 MongoDB 会返回 404。完成的标准是记录下原因,并且 MongoDB 测试能在所报告的环境中成功运行。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, mongodb, python
领域
databases, devops, testing-qa
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。