Can't install pip packages inside a docker container with windows

时光怂恿深爱的人放手 提交于 2020-08-10 18:53:28

问题


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"]

It is giving me this error

How to solve this proxy network error? I got solution for linux but for windows 10 i am not able to find any answer. I am using latest docker for windows.


回答1:


  • 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 .


来源:https://stackoverflow.com/questions/59973401/cant-install-pip-packages-inside-a-docker-container-with-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!