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

查看:181
本文介绍了无法在带有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,我找不到任何答案。我正在Windows上使用最新的docker。

推荐答案


  • 如果在以下命令之间使用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。

  • 如果您没有任何代理,请使用此命令(使用主机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天全站免登陆