I am currently following docker's doc on how to build an image using python
:
My "bug" could therefore be reproduced by following the doc.
I have checked & triple-checked my actions, and everything is exactly as the doc shows.
Also, i have looked at quite a few similar posts here, but none helped me resolve my problem.
For those that do not wish to look at the link, this is what i did:
The commands used :
$ cd /path/to/python-docker
$ pip3 install Flask
$ pip3 freeze > requirements.txt
$ touch app.py
afterward, we create the dockfile (NOTE: this is my dockfile, not the doc's):
FROM python:3.8-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
# RUN apt update && apt install -y python3-pip
# RUN pip install --upgrade setuptools
# NOTE: the 2 RUN above are the 2 latest attempts to find a solution by using a RUN line.
RUN pip3 install -r requirements.txt
COPY . .
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
and then:
$ docker build --tag python-docker .
[+] Building 2.7s (10/10) FINISHED
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 203B
=> [internal] load .dockerignore
=> => transferring context: 2B
=> [internal] load metadata for docker.io/library/python:3.8-slim-buster
=> [1/6] FROM docker.io/library/python:3.8-slim-buster
=> [internal] load build context
=> => transferring context: 953B
=> CACHED [2/6] WORKDIR /app
=> [3/6] COPY requirements.txt requirements.txt
=> [4/6] RUN pip3 install -r requirements.txt
=> [5/6] COPY . .
=> [6/6] CMD [ "python3", "-m", "flask", "run", "--host=0.0.0.0"]
=> exporting to image
=> => exporting layers
=> => writing image sha256:8cae92a8fbd6d091ce687b71b31252056944b09760438905b726625831564c4c
=> => naming to docker.io/library/python-docker
The above is the result that is supposed to happen. This is what i get:
$ sudo docker build --tag python-docker .
Sending build context to Docker daemon 16.38kB
Step 1/6 : FROM python:3.8-slim-buster
---> b426ee0e7642
Step 2/6 : WORKDIR /app
---> Using cache
---> 32f83359c4ca
Step 3/6 : COPY requirements.txt requirements.txt
---> Using cache
---> 2d84b2a8013a
Step 4/6 : RUN pip3 install -r requirements.txt
---> Running in de270828b1b5
ERROR: Could not find a version that satisfies the requirement apturl==0.5.2
ERROR: No matching distribution found for apturl==0.5.2
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1
While i could just delete this line from my requirements.txt
, the fact is that I did not write the file manually, and there is therefore no reason for it to be wrong. Regardless of that, apturl==0.5.2
is not the only one to have a similar error, and i estimate that around 40% of the content of requirements.txt
would produce the same error.
Me & my colleague have been stumped, and seeing that the solutions proposed in the similar posts that we have seen that we have yet to try spoke about manipulating DNS, i decided to create this question, since we aren't comfortable with playing with this in the workplace :D
NOTE: the sudo is simply because docker do not work without.
Thanks TERMINATOR for the edit!