简体   繁体   中英

Docker: COPY failed: file not found in build context or excluded by .dockerignore: stat go.mod

["

What I am trying to do: To build a docker image from inside Go\/node routine<\/strong><\/i>

FROM golang:1.18

WORKDIR /usr/src/app

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go build -v -o /usr/local/bin/app ./...

EXPOSE 3333


CMD ["app"]

Path to the root of the project updated. This solved the problem. Root cause may have been archive.TarWithOptions , not docker-sdk itself.

    tar, err := archive.TarWithOptions("./", &archive.TarOptions{})
    if err != nil {
        panic(err)
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM