尝试点子安装时,docker构建网络错误

时间:2020-07-26 23:26:39

标签: django docker build

作为学习django的一部分,我正在构建我的第一个docker安装。我的泊坞窗安装正常。 docker信息还可以。和hello-world表示成功。但是,当我运行Will Vincent在我的Django 3.0 Pro Book中建议的Dockerfile时。我收到了看起来像网络DNS错误的信息。

################# 错误:

    Step 6/7 : RUN pip install pipenv && pipenv install --system
 ---> Running in 585e5020f53a
    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 0x7f339144df10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
   
 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3391f05a90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
   
    WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3391f05e90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
    
    WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f3391f05ad0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
    
    WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f33915ddd90>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pipenv/
    
    ERROR: Could not find a version that satisfies the requirement pipenv (from versions: none)
    
    ERROR: No matching distribution found for pipenv
The command '/bin/sh -c pip install pipenv && pipenv install --system' returned a non-zero code: 1

####################

Dockerfile尝试构建:

拉动基本图像

FROM python:3.7

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set work directory
WORKDIR /code

# Install dependencies
COPY Pipfile Pipfile.lock /code/
RUN pip install pipenv && pipenv install --system

# Copy project
COPY . /code/

在RUN pip安装...行上失败。

我已经将dns域名服务器条目直接添加到了我的/etc/resolver.conf文件中,就像其他在我的搜索中建议的那样。没有用。

我认为Docker试图在容器中运行pip时出现了一些问题?这是我的第一个Docker安装,因此筋疲力尽地寻找答案。

在OS版本Centos8上

谢谢 比尔·桑德森

1 个答案:

答案 0 :(得分:0)

好的,我们可以尝试一些方法。我要做的第一件事:

  • 在Dockerfile中添加以下内容(带有Google的dns):

RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf && pip install pipenv && pipenv install --system

使用同一RUN命令进行操作很重要。

  • 另一个选择是:

docker build --network=host -t yourimage:yourversion .