1.centos上安装docker,安装git,安装go
2.将项目加入 Dockerfile :
FROM scratch
WORKDIR $GOPATH/src/github.com/EDDYCJY/go-gin-example
COPY . $GOPATH/src/github.com/EDDYCJY/go-gin-example
EXPOSE 8000
CMD ["./go-gin-example"]
3。编译gin项目生成可执行文件:CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o go-gin-example .
4,构建镜像:docker build -t gin-blog-docker-scratch .
5.生成容器并运行:docker run --link mysql:mysql -p 8000:8000 gin-blog-docker-scratch