Skip to content

Specifying GOTOOLCHAIN in golang:alpine fails #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chradcliffe opened this issue Aug 28, 2023 · 4 comments
Closed

Specifying GOTOOLCHAIN in golang:alpine fails #487

chradcliffe opened this issue Aug 28, 2023 · 4 comments

Comments

@chradcliffe
Copy link

The go command in golang:alpine doesn't seem to be able to find the path to the Go toolchain downloaded when specifying GOTOOLCHAIN:

❯ docker run --rm -it golang:alpine
Unable to find image 'golang:alpine' locally
alpine: Pulling from library/golang
Digest: sha256:445f34008a77b0b98bf1821bf7ef5e37bb63cc42d22ee7c21cc17041070d134f
Status: Downloaded newer image for golang:alpine
/go # GOTOOLCHAIN=go1.20.7 go version
go: downloading go1.20.7 (linux/amd64)
go: exec go1.20.7: no such file or directory
/go #

The same command works just fine in golang:latest:

❯ docker run --rm -it golang
Unable to find image 'golang:latest' locally
latest: Pulling from library/golang
de4cac68b616: Pull complete
d31b0195ec5f: Pull complete
9b1fd34c30b7: Pull complete
2f744fb50e06: Pull complete
661ee9827c7b: Pull complete
fa5c1764d694: Pull complete
Digest: sha256:b490ae1f0ece153648dd3c5d25be59a63f966b5f9e1311245c947de4506981aa
Status: Downloaded newer image for golang:latest
root@e76b63273844:/go# GOTOOLCHAIN=go1.20.7 go version
go: downloading go1.20.7 (linux/amd64)
go version go1.20.7 linux/amd64
root@e76b63273844:/go#

Is there something different about the PATH variable in golang:alpine that is causing issues here maybe?

@yosifkit
Copy link
Member

I think this is related to the fact that only go 1.21+ has binaries that work correctly on Alpine. (#474).

@chradcliffe
Copy link
Author

So if I understand correctly:

  • pre-1.21 golang:alpine was compiled from source because of cgo, but now 1.21 compiles without cgo, so the image uses the prebuilt official golang release.
  • Using pre-1.21 toolchains on 1.21+ golang:alpine won't work because those toolchains depend on cgo

Is that correct?

@yosifkit
Copy link
Member

That is correct; the upstream binary releases of 1.20.x don't work on Alpine.

@chradcliffe
Copy link
Author

That makes sense. Thank you for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants