【问题标题】:Docker connection error 'Connection broken by NewConnectionError'Docker 连接错误“连接被 NewConnectionError 破坏”
【发布时间】:2020-02-26 05:21:27
【问题描述】:

我是 docker 新手,我刚刚安装了它并为我的 django 项目做了一些配置。 当我运行时 docker build . 我收到这些错误 这里有什么问题?

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1363b604f0>: Failed to establish a new connection: [Errno -3] Try again')': /simple/django/

Dockerfile

FROM python:3.8-alpine
MAINTAINER RAHUL VERMA

ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

RUN mkdir /app
WORKDIR app
COPY ./app /app

RUN adduser -D user
USER user

requirements.txt 文件

Django==2.2
djangorestframework==3.11.0

【问题讨论】:

  • 检查您的互联网连接.....
  • 我尝试了不同的不同网络并得到了同样的错误。
  • 与 docker 网络无关,请检查您是否使用代理或其他东西阻止您与互联网的稳定连接
  • 代理服务器已在我的系统设置中关闭

标签: django python-3.x docker dockerfile


【解决方案1】:

我只是做一些小改动来使用你的 dockerfile 并运行命令 docker build -t app dockerfilelocation。 它在我身边工作。我的 dockerfile 看起来像 -

FROM python:3.8-alpine
MAINTAINER RAHUL VERMA

ENV PYTHONUNBUFFERED 1

COPY . /app/
RUN pip install -r /app/requirements.txt

RUN mkdir /app
WORKDIR app
COPY ./app /app

RUN adduser -D user
USER user

【讨论】:

  • docker build -t app 它给出了错误"docker build" requires exactly 1 argument.
  • 我已经在 cmd 中的 dockerfile 位置,同时运行 docker build -t app Dockerfile(这里 Dockerfile 是我的 docker 文件的名称)它给出了错误 `invalid argument "Dockerfile" '
  • 命令 docker build -t app . 其中 dot 告诉当前目录,如果您的 dockerfile 是另一个目录,那么您的命令 docker build -t app -f dirlocation . 例如,如果您的 dockerfile 在测试目录中,那么您的命令是 docker build -t app -f /test 。 您也可以从这里获取帮助 - stackoverflow.com/questions/29409310/…
  • 我在同一个 Dockerfile 目录中,但仍然出现同样的错误。
  • 我试过docker build ., docker build -t app Dockerfile & docker build -t app . 这些都给出了同样的错误。
【解决方案2】:

我遇到了同样的问题,我通过互联网连接解决了它,或者您可以通过以下方式进行检查:

“这几乎肯定是容器内的网络/DNS 配置的问题,与 pip 无关。尝试在 Dockerfile 中添加 RUN nslookup pypi.org 行,看看它是否有效. 如果您使用的是自定义索引 URL,请使用该 URL 而不是 pypi.org。”

https://github.com/pypa/pip/issues/7460

【讨论】:

    猜你喜欢
    • 2021-09-19
    • 1970-01-01
    • 2021-03-25
    • 1970-01-01
    • 2014-02-06
    • 1970-01-01
    • 2021-12-31
    • 2017-10-31
    • 2015-12-13
    相关资源
    最近更新 更多