调用“go get”时缺少Git命令`

调用“go get”时缺少Git命令`,go,package,Go,Package,我的Dockerfile FROM golang:1.10.2-alpine3.7 AS build RUN apk --no-cache add gcc g++ make ca-certificates RUN apk add git WORKDIR /go/src/github.com/meower COPY Gopkg.lock Gopkg.toml ./ COPY util util COPY event event COPY db db COPY search search COPY

我的Dockerfile

FROM golang:1.10.2-alpine3.7 AS build
RUN apk --no-cache add gcc g++ make ca-certificates
RUN apk add git
WORKDIR /go/src/github.com/meower

COPY Gopkg.lock Gopkg.toml ./
COPY util util
COPY event event
COPY db db
COPY search search
COPY schema schema
COPY meow-service meow-service
COPY query-service query-service
COPY pusher-service pusher-service

RUN go get -d -v ./...
RUN go install ./...

FROM alpine:3.7
WORKDIR /usr/bin
COPY --from=build /go/bin .
我添加了apk-add-git行。没有这行,我的docker-compose就产生了

Step 13/17 : RUN go get -d -v ./...
 ---> Running in d917adba00cd
github.com/lib/pq (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/lib/pq: exec: "git": executable file not found in $PATH
github.com/nats-io/go-nats (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/nats-io/go-nats: exec: "git": executable file not found in $PATH
github.com/gorilla/mux (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/mux: exec: "git": executable file not found in $PATH
github.com/kelseyhightower/envconfig (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/kelseyhightower/envconfig: exec: "git": executable file not found in $PATH
package github.com/retry: invalid github.com/ import path "github.com/retry"
github.com/segmentio/ksuid (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/segmentio/ksuid: exec: "git": executable file not found in $PATH
github.com/gorilla/websocket (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/gorilla/websocket: exec: "git": executable file not found in $PATH
github.com/olivere/elastic (download)
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/olivere/elastic: exec: "git": executable file not found in $PATH
有了git line,其他问题仍然存在

docker-compose up
Building pusher
Step 1/18 : FROM golang:1.10.2-alpine3.7 AS build
 ---> 44ccce322b34
Step 2/18 : RUN apk --no-cache add gcc g++ make ca-certificates
 ---> Using cache
 ---> 088fa5ba19a9
Step 3/18 : RUN apk add git
 ---> Running in 01022f57861b
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  git (missing):
这意味着什么?

go get内部调用特定VCS的参考客户端工具,用于托管要获取的包。换句话说,go-get本身不知道如何与VCS服务器交互

所以,是的,为了得到一个由Git托管的包,您需要工作的Git安装提供一个可调用的Git二进制文件

至于你的第二个问题,它,所以我建议你做一些研究,然后问一个单独的问题,如果失败了