1 DL3062
Moritz Röhrich edited this page 2025-09-24 10:46:38 +02:00

Problematic code:

Any of the following

RUN go install foobar
RUN go install barfoo@latest
RUN go get foobar
RUN go get barfoo@latest
RUN go run foobar
RUN go run barfoo@latest

Correct code:

Pin the versions of your dependencies or use code from the local filesystem:

RUN go install foobar@v1.2.3
RUN go install barfoo@v1.2.3
RUN go get foobar@v1.2.3
RUN go get barfoo@v1.2.3
RUN go run foobar@v1.2.3
RUN go run barfoo@v1.2.3
RUN go run .
RUN go run /go/app/foobar

Rationale:

Version pinning helps avoid unanticipated changes to the code and behavior. It also makes changes to dependencies obvious in source control systems and helps make builds more reproducible.