简体   繁体   English

'/bin/sh: go: not found' in 'docker:dind' 容器

[英]'/bin/sh: go: not found' in 'docker:dind' container

I try to install Golang (go1.13.9.linux-amd64) in docker-in-docker container( docker:dind ) manually (copy go binaries to a container).我尝试手动在 docker-in-docker 容器( docker:dind )中安装Golang (go1.13.9.linux-amd64)(将go二进制文件复制到容器中)。

Go was copied to /go/bin , Go被复制到/go/bin

/ # export GOROOT=/go
/ # export PATH=$GOROOT/bin:$PATH
/ # 
/ # uname -a
Linux 41868f6e7ae3 4.19.76-linuxkit #1 SMP Tue May 26 11:42:35 UTC 2020 x86_64 Linux
/ #
/ # echo $GOROOT
/go
/ #
/ # echo $PATH
/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I try check version and get an error:我尝试检查版本并收到错误:

/ # go version
/bin/sh: go: not found

I try add env to /etc/profile the same error.我尝试将env添加到/etc/profile相同的错误。

You did not mention the base image, but better to use on the of the base image either for go or docker-dind , I will recommend dind that is base on alpine and then install go .您没有提到基本映像,但最好在基本映像上使用godocker-dind ,我会推荐基于 alpine 的dind然后安装go

FROM docker:dind
RUN apk add --no-cache go
RUN go version

output output

Step 3/3 : RUN go version
 ---> Running in 123401c3ebad
go version go1.12.12 linux/amd64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM