Skip to content
Tanmay Pereira Naik edited this page Mar 8, 2024 · 5 revisions

Pin versions in apk add

Problematic code:

FROM alpine:3.7
RUN apk --no-cache add foo

Correct code (Partial pin glob):

FROM alpine:3.7
RUN apk --no-cache add foo=~1.2.3

Correct code (Exact pin):

FROM alpine:3.7
RUN apk --no-cache add foo=1.2.3

Note: Pinning exact versions can cause future builds to suddenly fail if that version is no longer available. Use with caution.

Available versions in apk can search on https://pkgs.alpinelinux.org

Rationale:

https://docs.docker.com/develop/develop-images/instructions/#run

Version pinning forces the build to retrieve a limited range of versions, or an exact particular version, regardless of what’s in the cache. This technique can also reduce failures due to unanticipated changes in required packages.

Clone this wiki locally