制作 golang 的 docker 镜像
2018-05-16 本文已影响99人
Jancd
自己动手定制了一个 golang 的 docker 镜像。
如图:请根据个人事迹情况修改
go_docker.png
DockerFile
FROM centos:latest
MAINTAINER SergeyChang <sergeychang@gmail.com>
LABEL Description="This is the golang development base on centOS"
#Reconfig timezone
#RUN echo "Asia/Shanghai" > /etc/timezone
#RUN yum -y update
# WORKDIR
WORKDIR /go
#env
ENV PATH /usr/local/go/bin:$PATH
ENV GOROOT /usr/local/go
ENV GOPATH /home/go
# install golang
ADD install_go.sh /
RUN chmod +x /install_go.sh \
&& /install_go.sh \
&& echo "Asia/Shanghai" > /etc/timezone
install_go.sh
#/bin/bash
# install wget
yum -y install wget
mkdir /home/go
# >>>> Watch out network !
wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
tar -C /usr/local -zxf go1.10.1.linux-amd64.tar.gz
# GOROOT
echo export GOROOT=/usr/local/go >> /etc/profile
# GOPATH
echo export GOPATH=/home/go >> /etc/profile
#
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
rm -f go1.10.1.linux-amd64.tar.gz
# say hello
echo ">>>>>>>"
go version
echo "<<<<<<<"