dockerrustraspberry-pi3

Why is Docker build failing to add a specific rust version?


I'm trying to build a docker image from Alpine and add a specific version of rust, but I'm getting this error and the build fails.

#7 [3/5] RUN apk add rust=1.72.1-r0
#7 4.203 fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/armv7/APKINDEX.tar.gz
#7 5.012 fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/armv7/APKINDEX.tar.gz
#7 6.228 ERROR: unable to select packages:
#7 6.405   rust-1.64.0-r2:
#7 6.405     breaks: world[rust=1.72.1-r0]
#7 ERROR: process "/bin/sh -c apk add rust=1.72.1-r0" did not complete successfully: exit code: 1

Here is my Dockerfile.

ARG version=3.9
ARG tag=${version}-alpine3.17

FROM python:${tag} as builder
WORKDIR /app
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true

RUN apk add rust=1.72.1-r0

RUN rustc -V

I'm building in on a Linux raspberrypi 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l GNU/Linux


Solution

  • If you check the version of Alpine Linux that the image in question is using, you will find it is 3.17.5:

    docker run --rm -it python:3.9-alpine3.17 cat /etc/os-release
    >>> NAME="Alpine Linux"
    >>> ID=alpine
    >>> VERSION_ID=3.17.5
    >>> PRETTY_NAME="Alpine Linux v3.17"
    >>> HOME_URL="https://alpinelinux.org/"
    >>> BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
    

    The version of Rust that is available for that version, is 1.64.0-r2.