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

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

问题描述

我正在尝试在Alpine Docker映像中安装Go.为此,我从此处下载了tar文件我的高山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:

export 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源代码,并在高山图像容器中执行了以下步骤.

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天全站免登陆