403 error when trying to install a deb package from debian mirrors during build

Dockerfile content:

FROM python:3.10-slim-bullseye

RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends --no-install-suggests \
    build-essential default-libmysqlclient-dev \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir --upgrade pip


WORKDIR /app


COPY ./requirements.txt /app
RUN pip install --no-cache-dir -r /app/requirements.txt

COPY . /app

EXPOSE 5000

CMD ["python3", "server.py"]

Error :

...
122.6 Setting up build-essential (12.9) ...
122.6 Processing triggers for libc-bin (2.31-13+deb11u7) ...
122.8 Errors were encountered while processing:
122.8  default-libmysqlclient-dev:amd64
122.8  libmariadb-dev
123.5 E: Failed to fetch http://deb.debian.org/debian/pool/main/m/mariadb-10.5/libmariadb3_10.5.21-0%2bdeb11u1_amd64.deb  403  connecting to deb.debian.org:80: connecting to 151.101.158.132:80: dial tcp 151.101.158.132:80: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [IP: 151.101.158.132 80]
123.5 E: Failed to fetch http://deb.debian.org/debian/pool/main/m/mariadb-10.5/libmariadb-dev-compat_10.5.21-0%2bdeb11u1_amd64.deb  403  connecting to deb.debian.org:80: connecting to 151.101.158.132:80: dial tcp 151.101.158.132:80: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [IP: 151.101.158.132 80]
123.5 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
Dockerfile:3
--------------------
   2 |
   3 | >>> RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends --no-install-suggests \
   4 | >>>     build-essential default-libmysqlclient-dev \
   5 | >>>     && apt-get clean \
   6 | >>>     && rm -rf /var/lib/apt/lists/*
   7 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y --fix-missing --no-install-recommends --no-install-suggests     build-essential default-libmysqlclient-dev     && apt-get clean     && rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 100

View build details: docker-desktop://dashboard/build/default/default/8g4qjl0jhepdq3ocj4odo2ana

I have python version 3.11. I have tried the same with python:3.11-slim-bullseye image. Tried using ubuntu instead of debian. It seems there is no response from debian repos ( understood by me ).

What do you meanby Docker Hub package? You have a Docke rimage, which could have been downloaded from any registry. The category indicates you feel you have problem with Docker Hub. Can you explain why?

Your porblem seems to be a failing command during docker build. The logs should show more details before the visible part on the screenshot. You can change the run instruction and run only part of it until you find out which part was failing if you have no error message.

Here is a blogpost about my presentation in which I showed more tricks. Video is in the post.


Also, please, use </> button to share codes, terminal outputs, error messages instead of sharing screenshots. That helps others to search for similar issues and us to read it more easily and quote parts of the message so we can help you more quickly. You can find a complete guide in the following post: How to format your forum posts

It was a mistake from my side to include docker hub. I have formatted the post correctly. I have also given all the parts of log that are related to the error. The part that is failing would be:

RUN apt-get update && apt-get install -y --fix-missing --no-install-recommends --no-install-suggests \
    build-essential default-libmysqlclient-dev \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

I meant debian repository and not docker hub package.

Thank you for sharing the code as text. Have you also tried what I suggested for debugging?

I have checked the ’ Solve Docker Build errors’ section in the blog you have shared. The error there was about ‘File or directory not found’, but in this case, There is no response coming from the debian repository and hence the second command in Dockerfile fails.

Please, share what you tried, because I can’T decide whether you did it right or not. And I don’t understand abve description perfectly.

I also had more suggestions in the video like debugging interactively. Build the container without the failing instructions and run the commands manually. Then you need to get error messages, but I believe you should have had more error messages even during the build since apt always shows want went wrong. At least I never saw it differently. Some outputs are hidden during the build after the commands ran, but the error messages are always shown if sent to the standard error stream. You can still try to run the docker build command with the “--progress plain” option which makes Docker show everything without rewriting the terminal output after executing the commands.

One thing I noticed though is that you are using the --fix-missing option. I don’t think that helps in a container unless the base image already had a problem with the apt packages. If it had, it becomes a Linux issue which I would definitely try to solve interactively and automate only when I managed to fix it interactively.