Docker for Golang应用程序 [英] Docker for golang application

查看:67
本文介绍了Docker for Golang应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有golang应用程序,我想为其构建docker映像名为 cloud-native-go 的应用程序文件夹,而dockerfile在根项目下知道这里有什么问题吗?

i've golang application which I want to build docker image for it the application folder called cloud-native-go and the dockerfile is under the root project Any idea what is wrong here ?

FROM golang:alpine3.7
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go-wrapper download   # "go get -d -v ./..."
RUN go-wrapper install    # "go install -v ./..."

#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app
LABEL Name=cloud-native-go Version=0.0.1
EXPOSE 3000

错误是:

Step 5/12 : RUN go-wrapper download   # "go get -d -v ./..."
 ---> Running in 70c2e00f332d
/bin/sh: go-wrapper: not found

i用

docker build -t cloud-native-go:1.0.0.

推荐答案

go-wrapper 已被弃用,并已使用 go 10及更高版本从图像中删除.请参见此处.

go-wrapper has been deprecated and removed from the images using go version 10 and above. See here.

如果您很好地使用 go v1.9 ,则可以使用以下图像: golang:1.9.6-alpine3.7 .

If you are fine using go v1.9 you can use the following image: golang:1.9.6-alpine3.7.

因此,您的 Dockerfile 将是:

FROM golang:1.9.6-alpine3.7
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go-wrapper download   # "go get -d -v ./..."
RUN go-wrapper install    # "go install -v ./..."

#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app
LABEL Name=cloud-native-go Version=0.0.1
EXPOSE 3000

这篇关于Docker for Golang应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆