无法在带有 Windows 的 docker 容器内安装 pip 包 [英] Can't install pip packages inside a docker container with windows

查看:41
本文介绍了无法在带有 Windows 的 docker 容器内安装 pip 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dockerfile

# Use an official Python runtime as a base image
FROM python:3.8.1-windowsservercore

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]

它给了我这个错误

如何解决这个代理网络错误?我得到了 linux 的解决方案,但对于 windows 10,我找不到任何答案.我正在使用最新的 docker for windows.

推荐答案

  • 如果您在使用以下命令之间有 n/w 代理:
    docker build --no-cache --build-arg HTTP_PROXY=http://xx.xx.xx.xx:xx --build-arg HTTPS_PROXY=http://xx.xx.xx.xx:xx --network=host -t helloworkapp .
  • 如果您没有任何代理,请使用此命令(使用 host n/w 下载软件包):
    docker build --no-cache --network=host -t helloworkapp.
    • If you have n/w proxy in between use below command :
      docker build --no-cache --build-arg HTTP_PROXY=http://xx.xx.xx.xx:xx --build-arg HTTPS_PROXY=http://xx.xx.xx.xx:xx --network=host -t helloworkapp .
    • If you don't have any proxy use this command (use host n/w for downloading packages):
      docker build --no-cache --network=host -t helloworkapp .
    • 这篇关于无法在带有 Windows 的 docker 容器内安装 pip 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆