简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM