1、使用容器卷在ubuntu容器和主机之间共享目录
- sudo docker run -it -v /home/ocean/myvolume:/dataVolumeContainer ubuntu
2、安装go1.4设置Go的环境变量GOROOT_BOOTSTRAP 这个目录在安装 Go 1.5 版本及之后的版本时需要设置。由于在 1.4 版本后,Go 编译器实现了自举,即通过 1.4 版本来编译安装之后版本的编译器。如果不设置该环境变量的话,会产生这样一个错误“Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.”。
2.1、下载源码包方法1:
- cd /usr/localapt-get update 【安装install工具,解决E: Unable to locate package wget】* apt-get install wget 【bash: wget: command not found】
- wget https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.
- tar.gztar -xvf go1.4-bootstrap-20170531.tar.gz
2.2、安装
- apt-get install gcc【gcc: command not found】
- cd go/src
- ./make.bash
设置环境变量
- cd …/…
- mv go go1.4
- echo export GOROOT_BOOTSTRAP=/usr/local/go1.4 >> /etc/profile
- source /etc/profile
3、下载最新的golang11源码包
- cd /usr/local
- uname -a 【linux的架构x86_64】
- 直接从https://studygolang.com/dl选择linux版本的源码包然后将包放入/usr/local目录下* tar -xvf go1.11.linux-amd64.tar.gz
- cd go/src将一个好的ubuntu下的/etc/services复制到容器的/etc目录下【 cgo_unix_test.go:48: lookup tcp/smtp: Servname not supported for ai_socktype】
- ./all.bash
结果:os/user with tag osusergo
— FAIL: TestCurrent (0.00s)
user_test.go:37: Current: user: Current not implemented on linux/amd64 (got (*user.User)(nil))
— FAIL: TestLookup (0.00s)
user_test.go:80: Current: user: Current not implemented on linux/amd64
— FAIL: TestLookupId (0.00s) u
ser_test.go:101: Current: user: Current not implemented on linux/amd64
尝试:进入os/user目录,将user_test.go的第37、80、101行注释掉
结果:panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference[signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x4f0b8b]
安装失败,无法解决
参考:https://blog.csdn.net/wuxing26jiayou/article/details/79694735
总结:先前我安装的go是最新版的11,安装失败。无论是容器还是ubuntu主机中。安装10