从同一主机上的另一个Docker容器连接到Milvus独立服务器(在Docker容器中)

mnemlml8  于 2022-11-28  发布在  Docker
关注(0)|答案(1)|浏览(642)

当我在Docker上以独立模式运行Milvus时(通过在默认的Milvus docker-compose.yml文件上执行docker-compose.yml,创建了三个容器),我无法从同一主机上的另一个docker容器中运行的任务连接到Milvus服务器。我已将此容器配置为与Milvus服务器在同一网络上,我可以从这个容器通过Milvus服务器的IP ping Milvus服务器。
在我运行的任务容器中:

connections.connect(
    alias="default", 
    host='192.168.192.4', 
    port='19530',
    secure=False
    )

错误日志显示:

Traceback (most recent call last):
File "task.py", line 45, in
secure=True
File "/usr/local/lib/python3.7/site-packages/pymilvus/orm/connections.py", line 262, in connect
connect_milvus(**kwargs, password=password)
File "/usr/local/lib/python3.7/site-packages/pymilvus/orm/connections.py", line 233, in connect_milvus
gh._wait_for_channel_ready()
File "/usr/local/lib/python3.7/site-packages/pymilvus/client/grpc_handler.py", line 118, in _wait_for_channel_ready
raise MilvusException(Status.CONNECT_FAILED, f'Fail connecting to server on {self._address}. Timeout')
pymilvus.exceptions.MilvusException: <MilvusException: (code=2, message=Fail connecting to server on 192.168.192.4:19530. Timeout)>

192.168.192.4 是milvus独立容器的IP地址。

8cdiaqws

8cdiaqws1#

结果发现这不是Milvus的问题。问题是由我们的公司网络和代理要求引起的。在dockerfile中,我需要设置代理设置才能拉取图像。但是,这在构建过程中为容器设置了代理设置。这些代理设置阻止了容器之间的通信。代理设置需要在dockerfile中重置。修复如下:

FROM python:3.9.12

ENV https_proxy <proxy settings>

COPY requirements.txt /

RUN pip3 install --proxy <proxy settings> -r requirements.txt

COPY task.py /

ENV https_proxy ""

CMD ["python3", "-u", "task.py"]

相关问题