Image Overview: go

Overview: go Chainguard Image

Container image for building Go applications.

Get It!

The image is available on

docker pull


NOTE: As of 12/30/2022, the default go image uses Wolfi, which is glibc based.

If you were using this image before and are now running into trouble, the musl/Alpine based image is still available at

Host architecture example

To build the Go application in tests/hello/main.go using the host architecture:

docker run --rm -v "${PWD}:/work" -w /work/tests/hello \
    -e GOOS="$(go env GOOS)" -e GOARCH="$(go env GOARCH)" \ build -o /work/hello .

The example application will be built to ./hello:

$ ./hello
Hello World!

Secure-by-default Features

In Go 1.20, we default to using the new GODEBUG settings of tarinsecurepath=0 and zipinsecurepath=0. These can be disabled by clearing the GODEBUG environment variable, or by setting them to 1.

Learn more about these settings in the Go release notes.

Dockerfile example

The following example Dockerfile builds a hello-world program in Go and copies it on top of the base image:

# syntax=docker/dockerfile:1.4
FROM as build


COPY <<EOF go.mod
module hello
go 1.19

COPY <<EOF main.go
package main
import "fmt"
func main() {
    fmt.Println("Hello World!")
RUN go build -o hello .


COPY --from=build /work/hello /hello
CMD ["/hello"]

Run the following command to build the demo image and tag it as go-hello-world:

docker build -t go-hello-world  .

Now you can run the image with:

docker run go-hello-world

You should get output like this:

Hello World!

It’s worth noting how small the resulting image is:

docker images go-hello-world
go-hello-world   latest    859fedabd532   5 hours ago   3.21MB