I am attempting to build a Docker image for my Python web server, but I keep receiving the error message No matching distribution found for <package-name>
. In my case the package I was trying to install was alembic 1.11.1 but as you will see bellow, this is not about a specific package.
This error only occurs when I am connected to the tp-link wi-fi extender.
In detail, the error is the following:
$ docker build -t test
[+] Building 56.3s (9/10)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 354B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.10-alpine 1.6s
=> CACHED [1/6] FROM docker.io/library/python:3.10-alpine@sha256:a578a0d69e5df6a9d7af73699553dc80717b2871a24cc9536130a40512b41295 3.1s
=> [internal] load build context 7.5s
=> => transferring context: 3.59kB 0.0s
=> [2/6] WORKDIR /code 4.5s
=> [3/6] COPY ./requirements.txt /code/requirements.txt 0.0s
=> [4/6] COPY ./alembic.ini /code/alembic.ini 0.1s
=> ERROR [5/6] RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt 46.9s
------
> [5/6] RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt:
#0 9.171 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 0x7f9a8b718640>: Failed to establish a new connection: [Errno -3] Try again')': /simple/alembic/
#0 14.68 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 0x7f9a8b718af0>: Failed to establish a new connection: [Errno -3] Try again')': /simple/alembic/
#0 20.68 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 0x7f9a8b718f70>: Failed to establish a new connection: [Errno -3] Try again')': /simple/alembic/
#0 27.69 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 0x7f9a8b719120>: Failed to establish a new connection: [Errno -3] Try again')': /simple/alembic/
#0 36.70 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 0x7f9a8b7193f0>: Failed to establish a new connection: [Errno -3] Try again')': /simple/alembic/
#0 41.71 ERROR: Could not find a version that satisfies the requirement alembic==1.11.1 (from versions: none)
#0 41.71 ERROR: No matching distribution found for alembic==1.11.1
------
Dockerfile:8
--------------------
6 | COPY ./alembic.ini /code/alembic.ini
7 |
8 | >>> RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
9 |
10 | COPY ./app /code/app
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install --no-cache-dir --upgrade -r /code/requirements.txt" did not complete successfully: exit code: 1
On the other hand, when Ι am connected directly to the router, running the same command (i.e. docker build -t test
) builds the image without any issue.
In case this was not a network issue I have tried the following (while connected to the wifi extender):
I specified the platform as x86_64
, as suggested in other threads, but this did not solve the problem. Furthermore, I have also tried changing the base image to various other versions, such as python:3.10-bullseye
, python:3.10-bookworm
, and python:3.10-slim
.
I have also tried deleting the specific alembic version but the problem still persisted. Then I tried deleting the whole alembic requirement but then I would get the same error for the next package, meaning that this is a package-agnostic error, not being able to install any dependency of my project.
The Dockerfile
I am using is this:
FROM --platform=x86_64 python:3.10-alpine
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
COPY ./alembic.ini /code/alembic.ini
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app
EXPOSE 80
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
the requirements.txt
file is this (I repeat, the packages here do not play any role on error that occurs):
alembic==1.11.1
anyio==3.6.2
bcrypt==4.0.1
certifi==2023.5.7
click==8.1.3
colorama==0.4.6
dnspython==2.3.0
ecdsa==0.18.0
OS and tool versions:
- Ubuntu 22.04.2 LTS x86_64
- Docker version 24.0.2, build cb74dfc
- Wi-Fi extender device: TL-WA860RE