http://ask.loongnix.org/?/article/90
一、下载portainer官方镜像
1.在loongnix上下载镜像
[root@loongson ~]# docker pull docker.io/portainer/portainer:1.14.3 Using default tag: 1.14.3 Trying to pull repository docker.io/portainer/portainer ... unauthorized: authentication required
2.根据控制台反馈结果unauthorized: authentication required,提示无权限,因为该镜像不支持 mips64el,所以无法下载镜像到本地,可使用X86机器进行下载该镜像
[root@X86 ~]# docker pull docker.io/portainer/portainer:1.14.3
3.提示下载成功,查看本地镜像
[root@X86 ~]# docker images REPOSITORY TAG IMAGE ID docker.io/portainer/portainer 1.14.3 457fb8fa57b0
4.确认本地镜像docker.io/portainer/portainer已存在,运行该镜像
[root@X86 ~]# docker run -i -t docker.io/portainer/portainer:1.14.3
5.使用Docker export命令导出当前镜像创建的容器为tar包
[root@X86 ~]# docker export 36ceef361070 > loongson-portainer.tar
6.将loongson-portainer.tar包拷贝到loongson机器上,这里使用scp命令进行拷贝
[root@X86 ~]# scp loongson-portainer.tar root@10.20.42.19:/root/portainer/
7.在loongnix机器上解压loongson-portainer.tar
[root@loongson portainer]# tar xf loongson-portainer.tar
8.经分析,需要重新编译的二进制文件为portainer
[root@loongson portainer]# file portainer portainer: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
接下来,从github下载portainer源代码,重新编译portainer
二、从github下载portainer源代码
1.设置GO语言参数—GOPATH
export GOPATH=/usr/share/gocode
2.使用go get 从github中下载源代码
[root@loongson portainer]# go get github.com/portainer/portainer package github.com/portainer/portainer: no buildable Go source files in /usr/share/gocode/src/github.com/portainer/portainer
这里出现了错误提示,但是没有关系,go get 命令相当于先下载,再安装两个步骤,上面的提示是安装失败,我们需要的是源代码,因此可以忽略此提示
3.打开源代码所在文件夹
[root@loongson portainer]# cd $GOPATH/src/github.com/portainer/portainer
4.因为只需要编译源代码中的api部分所以将此文件夹下的其他内容全部删除
[root@loongson portainer]# rm -rf app assets bower.json build build.sh codefresh.yml CODE_OF_CONDUCT.md CONTRIBUTING.md gruntfile.js index.html LICENSE package.json README.md test vendor.yml distribution
5.因为go语言文件中的的目录的相对路径和源代码中的相对路径不同,所以需要对源代码的相对路径做调整
[root@loongson portainer]# cp -rf api/* $GOPATH/src/github.com/portainer/portainer
6.删除源代码中的api文件夹
[root@loongson portainer]# rm -rf api/
三、编译portainer源代码
1.打开main.go所在目录
[root@loongson portainer]# cd $GOPATH/src/github.com/portainer/portainer/cmd/portainer
2.执行go build 命令,开始进行代码编译
[root@loongson portainer]# go build main.go ../../../../../gopkg.in/alecthomas/kingpin.v2/usage.go:10:2: cannot find package "github.com/alecthomas/template" in any of: /usr/lib/golang/src/github.com/alect