如何在 alpine linux 中安装 Go [英] How to install Go in alpine linux

查看:47
本文介绍了如何在 alpine linux 中安装 Go的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Alpine Docker 映像中安装 Go.为此,我从 here 下载了 tar 文件我的 alpine docker 镜像,使用以下命令解压它:

I am trying to install Go inside an Alpine Docker image. For that I downloaded tar file from here inside my alpine docker image, untar it using following command:

tar -C/usr/local -xzf go1.10.3.linux-amd64.tar.gz

tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz

导出的 PATH 为二进制:

exported PATH to have go binary as:

导出 PATH=$PATH:/usr/local/go/bin

export PATH=$PATH:/usr/local/go/bin

但是,当我说 go version 时,它会说 sh: go: not found.我对高山很陌生.有谁知道,我在这里缺少什么?

However, when I say go version then it says that sh: go: not found. I am quite new to alpine. Does anyone know, what I am missing here?

复制步骤-

$ docker run -it alpine sh
$ wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
$ tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz
$ export PATH=$PATH:/usr/local/go/bin
$ go version

推荐答案

感谢BMitch.

我编译了 go 源代码并在 alpine 图像容器中执行了以下步骤.

I compiled the go source code and performed the below steps inside alpine image container.

echo "installing go version 1.10.3..." 
apk add --no-cache --virtual .build-deps bash gcc musl-dev openssl go 
wget -O go.tgz https://dl.google.com/go/go1.10.3.src.tar.gz 
tar -C /usr/local -xzf go.tgz 
cd /usr/local/go/src/ 
./make.bash 
export PATH="/usr/local/go/bin:$PATH"
export GOPATH=/opt/go/ 
export PATH=$PATH:$GOPATH/bin 
apk del .build-deps 
go version

这篇关于如何在 alpine linux 中安装 Go的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆