Hi there. I’m pretty much new to Docker and my first try says:
2025-02-03 19:39:16 2025/02/03 18:39:16 loading imports: exec: “go”: executable file not found in $PATH
It’s quit clear what this means, but if Docker only looks in this $PATH:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
then it is quit obvious that it’s not going to find my GO file.
So, how do I set the $PATH so that Docker will find my GO executable?
A little bit more context could get you more help, but let’s see what I can say.
I’m not sure what PATH value did you share, but assuming you executed a command in the container and got tthis value back when running echo $PATH
, if go cannot be found, you probably don’t use an official GO image. If you make your own image, add the path of your go excutable’s directory to the PATH variable in a Dockerfile
ENV PATH="$PATH:/your/go/path/bin"
Or if the error message comes during build, if yo don’t want to add go to the PATH, you can use absolute path when referring to the go executable.
Yes, I suspect that in the course I follow, we make our own image - what ever that may be. So I’ll try again when I inserted the PATH.
Excuse me but what do you mean by: “Or if the error message comes during build, if yo don’t want to add go to the PATH, you can use absolute path when referring to the go executable.”
Will you explain please?
I meant you can use
/your/go/installation/path/bin/go
or similar instead of just
go
in a Dockerfile, but you would probably not prefer that interactively. That is why I wrote “during build”