How can pip install be used with docker windows container?

Viewed 438

I am trying to build a Windows docker container. Here is my Dockerfile:

FROM python:3
WORKDIR /project
COPY ./requirements.txt /project/requirements.txt
RUN pip install -r requirements.txt
COPY ./forever.exe /project/exec.exe
CMD [ "/project/exec.exe", "main.py" ]
COPY . /project

Here is my requirements.txt file:

h5py==2.10.0
joblib==0.14.1
numpy==1.19.5
tables==3.6.1
tensorflow==2.4.1
pandas==1.2.1
python_dateutil==2.8.1

I run the command

docker build -t my-image .

in an Anaconda prompt in order to build the image. The build works okay until it gets to the line

RUN pip install -r requirements.txt

At that point I get the error

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x000002C87EA274C0>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed')': /simple/h5py/

ERROR: Could not find a version that satisfies the requirement h5py==2.10.0

ERROR: No matching distribution found for h5py==2.10.0

The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; pip install -r requirements.txt' returned a non-zero code: 1

Following the answer given at the Stackoverflow link Can't install pip packages inside a docker container with windows, I tried the command

docker build --no-cache --network=host -t my-image .

since I don't have a proxy server. I now get the error

network host not found when the build gets to the

RUN pip install -r requirements.txt

line of the dockerfile.

Is there any way to fix this issue?

0 Answers
Related