0

I am trying to build docker image of my python code and getting Error in build. Following is my docker file :

FROM python:3.10.0-alpine
WORKDIR /mymd

COPY . .

# Install the requirements specified in file using RUN
RUN pip install --no-cache-dir -r requirements.txt

# Expose port 8787 to the outside world
EXPOSE 8787

# command to run when image is executed inside a container
CMD [ "python3", "mymd.py" ]

Error in Docker build time is as follows :

pache@dev5 ~/ROOT/SourceCode/amd $ docker build -t amd .
[+] Building 54.2s (9/9) FINISHED                                                                                                       docker:default
 => [internal] load build definition from Dockerfile                                                                                              0.1s
 => => transferring dockerfile: 575B                                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                                 0.1s
 => => transferring context: 2B                                                                                                                   0.0s
 => [internal] load metadata for docker.io/library/python:3.10.12-alpine                                                                          0.8s
 => [1/5] FROM docker.io/library/python:3.10.12-alpine@sha256:a578a0d69e5df6a9d7af73699553dc80717b2871a24cc9536130a40512b41295                    0.0s
 => [internal] load build context                                                                                                                 0.1s
 => => transferring context: 2.15kB                                                                                                               0.0s
 => CACHED [2/5] WORKDIR /mymd                                                                                                                0.0s
 => [3/5] COPY . .                                                                                                                                0.2s
 => [4/5] RUN pip install pip                                                                                                                     8.8s
 => ERROR [5/5] RUN pip install --no-cache-dir -r requirements.txt                                                                               44.0s
------                                                                                                                                                 
 > [5/5] RUN pip install --no-cache-dir -r requirements.txt:                                                                                           
6.256 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 0x7f05597a37c0>: Failed to establish a new connection: [Errno -3] Try again')': /simple/antiorm/      
11.76 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f05597a1390>: Failed to establish a new connection: [Errno -3] Try again')': /simple/antiorm/      
17.77 WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f05597a2d40>: Failed to establish a new connection: [Errno -3] Try again')': /simple/antiorm/
24.77 WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f05597a3040>: Failed to establish a new connection: [Errno -3] Try again')': /simple/antiorm/
33.78 WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f05597a31c0>: Failed to establish a new connection: [Errno -3] Try again')': /simple/antiorm/
38.79 ERROR: Could not find a version that satisfies the requirement antiorm==1.2.1 (from versions: none)
38.79 ERROR: No matching distribution found for antiorm==1.2.1
------
Dockerfile:14
--------------------
  12 |     RUN pip install pip
  13 |     # Install the requirements specified in file using RUN
  14 | >>> RUN pip install --no-cache-dir -r requirements.txt
  15 |     
  16 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install --no-cache-dir -r requirements.txt" did not complete successfully: exit code: 1
apache@dev5 ~/ROOT/SourceCode/AuxModel $ 

Would like to know your inputs so that i can try them out and check if it gets resolved.

Thanks

atul ahire
  • 127
  • 9

1 Answers1

0

Your problem is the network connection to the py server.

It works with the default config on my setup when I build.

enter image description here

If you are working with Linux or WSL2:

Pls check it:

'sudo nano /etc/resolv.conf' > nameserver 8.8.8.8

Ömer Sezer
  • 197
  • 5
  • I verfied it and i do have nameserver 8.8.8.8 in resolv.conf – atul ahire Jul 20 '23 at 14:43
  • You have a network issue on your host or docker image, or corporate network proxy, firewall blocks it. It could be anywhere. Pls test/proceed it step by step. First try to install on your host machine "python3 -m pip install antiorm==1.2.1" or "python3 -m pip install pandas", then have look docker config. In your network system, is there any proxy? If there is proxy, you have to configure docker.. – Ömer Sezer Jul 20 '23 at 14:52