Issues with Docker Build: Unable to Install Packages on Alpine 3.19

Hi everyone,

I’m experiencing an issue while building my Docker images using Alpine 3.19. The build fails during the installation of system packages, with the following error messages:


WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.19/main: temporary error (try again later)
ERROR: unable to select packages:
  g++ (no such package):
    required by: world[g++]
  libffi-dev (no such package):
    required by: world[libffi-dev]
  make (no such package):
    required by: world[make]
  python3-dev (no such package):
    required by: world[python3-dev]


Here are the relevant parts of my Dockerfiles for both the web server and worker:


# Build image
FROM python:3.11-alpine3.19 AS build

# Other instructions...

ARG PACKAGES='\
   g++ make python3-dev \
    libffi-dev \
'

RUN echo "Install system packages" && \
    apk add --no-cache $PACKAGES

# Production image
FROM python:3.11-alpine3.19

ARG RUNTIME_PACKAGES='\
    dumb-init \
'

RUN echo "Install runtime packages" && \
    apk update && \
    apk add --no-cache $RUNTIME_PACKAGES


Things I’ve tried:

  1. Retrying the build multiple times in case it was a temporary network issue.

Questions:

  • Has anyone encountered a similar issue?
  • Is there a recommended approach to ensure successful package installation in Alpine-based Docker images?

Any help or insights would be greatly appreciated!

Thank you!

I just built the dockerfile snippet you added, it worked fine…
Try re-pulling the base image, perhaps it is outdated

1 Like

When I run ktd --debug up in the repository, it throws me this(the whole traceback):


donko@donko-Latitude-5550:~/Desktop/EDITED/browser-farm$ ktd --debug up
Log level: DEBUG
Listing Docker containers with labels=['com.docker.compose.oneoff=False', 'com.docker.compose.project=browserfarmdev']
--> Building any out of date containers
--> Updating docker/Dockerfile_webserver
Listing Docker containers with labels=['com.docker.compose.oneoff=False', 'com.docker.compose.project=browserfarmdev']
--> Injecting environment variables:
    KTD_ENV=dev
    DEV_SMART_PROXY_INFLUXDB=smart-proxy-influxdb
    DEV_SMART_PROXY=smart-proxy
    DEV_SMART_PROXY_GRAFANA=smart-proxy-grafana
--> Executing: /home/donko/.pyenv/versions/3.9.18/bin/python3.9 -m compose --project-directory . --project-name browserfarmdev --file /home/donko/Desktop/EDITED/browser-farm/.kubetools/dev-compose.yml build --pull webserver
Building webserver
[+] Building 11.9s (9/20)                                                                                                                   docker:desktop-linux
 => [internal] load build definition from Dockerfile_webserver                                                                                              0.0s
 => => transferring dockerfile: 1.30kB                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/python:3.11-alpine3.19                                                                                   1.5s
 => [internal] load .dockerignore                                                                                                                           0.0s
 => => transferring context: 95B                                                                                                                            0.0s
 => [internal] load build context                                                                                                                           0.0s
 => => transferring context: 893B                                                                                                                           0.0s
 => CACHED [build 1/7] FROM docker.io/library/python:3.11-alpine3.19@sha256:5b5d84673d8311a1053ab06e74959de070f0021303e05e76acab7f7f15fcfec4                0.0s
 => => resolve docker.io/library/python:3.11-alpine3.19@sha256:5b5d84673d8311a1053ab06e74959de070f0021303e05e76acab7f7f15fcfec4                             0.0s
 => CACHED [build 2/7] RUN addgroup -S edited && adduser -S edited -G edited                                                                                0.0s
 => CACHED [build 3/7] WORKDIR /opt/app                                                                                                                     0.0s
 => ERROR [build 4/7] RUN echo "Install system packages" &&     apk add --no-cache    g++ make python3-dev     libffi-dev                                  10.3s
 => ERROR [stage-1  2/10] RUN echo "Install runtime packages" &&     apk update &&     apk add --no-cache     dumb-init                                    10.3s
------                                                                                                                                                           
 > [build 4/7] RUN echo "Install system packages" &&     apk add --no-cache    g++ make python3-dev     libffi-dev :                                             
0.161 Install system packages                                                                                                                                    
0.177 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz                                                                              
5.184 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/APKINDEX.tar.gz                                                                         
5.184 WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.19/main: temporary error (try again later)                                                      
10.19 WARNING: fetching https://dl-cdn.alpinelinux.org/alpine/v3.19/community: temporary error (try again later)                                                 
10.19 ERROR: unable to select packages:                                                                                                                          
10.19   g++ (no such package):                                                                                                                                   
10.19     required by: world[g++]
10.19   libffi-dev (no such package):
10.19     required by: world[libffi-dev]
10.19   make (no such package):
10.19     required by: world[make]
10.19   python3-dev (no such package):
10.19     required by: world[python3-dev]
------
------
 > [stage-1  2/10] RUN echo "Install runtime packages" &&     apk update &&     apk add --no-cache     dumb-init     :
0.167 Install runtime packages
0.175 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
5.183 fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
5.183 WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.19/main: temporary error (try again later)
10.19 WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.19/community: temporary error (try again later)
10.19 4 unavailable, 0 stale; 38 distinct packages available
------

 2 warnings found (use docker --debug to expand):
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 36)
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 37)
Dockerfile_webserver:32
--------------------
  31 |     
  32 | >>> RUN echo "Install runtime packages" && \
  33 | >>>     apk update && \
  34 | >>>     apk add --no-cache $RUNTIME_PACKAGES
  35 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c echo \"Install runtime packages\" &&     apk update &&     apk add --no-cache $RUNTIME_PACKAGES" did not complete successfully: exit code: 4

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/iedtlz41g2fmo2khjz4w4gchx
ERROR: Service 'webserver' failed to build
--> Kubetools dev exception: External process failed: ['/home/donko/.pyenv/versions/3.9.18/bin/python3.9', '-m', 'compose', '--project-directory', '.', '--project-name', 'browserfarmdev', '--file', '/home/donko/Desktop/EDITED/browser-farm/.kubetools/dev-compose.yml', 'build', '--pull', 'webserver']


Since @deanayalon is able to build the image, you are most likely affected by a network problem:

  • either on your host or in your local network
  • the regional cdn endpoint for dl-cdn.alpinelinux.org you get connected to
  • somewhere between your local network and the cdn endpoint.