Skip to content
Moritz Röhrich edited this page Sep 24, 2025 · 1 revision

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.

Clone this wiki locally