so here’s the story, this is my first time using docker because i was told it is really easy to deploy script, model and many more. Today i try to build my first docker image for my python script using flask. i try to build it and it work on the first couple of iteration and fail like 10 times on the RUN section this is the log
[+] Building 9.7s (9/10) docker:default
=> [internal] load build definition from Dockerfile 0.9s
=> => transferring dockerfile: 682B 0.0s
=> [internal] load .dockerignore 1.3s
=> => transferring context: 58B 0.0s
=> [internal] load metadata for docker.io/library/python:3.9 4.5s
=> [auth] library/python:pull token for registry-1.docker.io 0.0s
=> [1/5] FROM
=> [internal] load build context 0.3s
=> => transferring context: 74B 0.0s
=> CACHED [2/5] WORKDIR /flask-finding-driver 0.0s
=> CACHED [3/5] COPY finding_driver.py requirements.txt /flask-finding-driver/ 0.0s
=> ERROR [4/5] RUN python -m pip install --upgrade pip 2.1s
------
> [4/5] RUN python -m pip install --upgrade pip:
1.565 exec /bin/sh: exec format error
------
Dockerfile:11
--------------------
9 |
10 | # Install any needed packages specified in requirements.txt
11 | >>> RUN python -m pip install --upgrade pip
12 | RUN pip install -r requirements.txt
13 |
--------------------
ERROR: failed to solve: process "/bin/sh -c python -m pip install --upgrade pip" did not complete successfully: exit code: 1
. well of course because of this i search on many places for advice and implement it like dont upgrade pip, use python3, dont use pip to upgrade pip, dont run pip at all, etc i try everything and still fail. also when i delete this line
RUN python -m pip install --upgrade pip
it created another error same like this but for requirements.txt
this is my dockerfile
FROM python:3.9
WORKDIR /flask-finding-driver
COPY finding_driver.py requirements.txt /flask-finding-driver/
RUN python -m pip install --upgrade pip
RUN pip install -r requirements.txt
EXPOSE 5000
ENV FLASK_APP=finding_driver.py
CMD ["flask", "run", "--host=0.0.0.0"]
thank you if youre answering this question really need it fast
Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.
Example code block:
```
echo "I am a code."
echo "An athletic one, and I wanna run."
```
This will show if the image has thr wrong architetcure somehow. If it is not amd64, you could try to delete the image and try again running the previous twst commands.
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7efec0043bb0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution’)': /simple/pip/
How is it the same error? You have a DNS resolution failure and the original issue was exec format error. Don’t let yourself to be confused by the general title.