5 DL3018
Tanmay Pereira Naik edited this page 2024-03-08 17:07:02 +05:30
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 whats in the cache. This technique can also reduce failures due to unanticipated changes in required packages.