Trying to dockerize Django app receive error "ERROR [3/6] RUN apk update"

Question:

I’m completely new to Dockers, I’m trying to dockerize a Django application using:

FROM python:3.10.4-alpine3.15

ENV PYTHONUNBUFFERED=1

WORKDIR /app

RUN  apk update 
    && apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev 
    && pip install --upgrade pip

COPY ./requirements.txt ./

RUN pip install -r requirements.txt

COPY ./ ./

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

But when I run docker build -t sometag . I receive the following error:

 ERROR [3/6] RUN  apk update  && apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev  && pip install --upgrade pip                                                                               10.5s
------
 > [3/6] RUN  apk update        && apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev        && pip install --upgrade pip:
#6 0.396 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
#6 5.402 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
#6 5.402 ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.15/main: temporary error (try again later)
#6 5.402 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/main: No such file or directory
#6 10.41 ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.15/community: temporary error (try again later)
#6 10.41 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/community: No such file or directory
#6 10.41 2 errors; 36 distinct packages available
------
executor failed running [/bin/sh -c apk update  && apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev        && pip install --upgrade pip]: exit code: 2
Asked By: Carlos S. C.

||

Answers:

Well, it obvious is failing at your bash commands.

Be careful with indentation, it is very important in bash commands.

RUN apk update 
    && apk add --no-cache gcc musl-dev postgresql-dev python3-dev libffi-dev 
    && pip install --upgrade pip

If not that, than one of your libs.

Answered By: Niko
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.