Unexpected NUL in input, how to build docker

I am trying to build my project inside the docker, so here are my Dockerfile looks like

build stage

FROM golang as builder

ENV GO111MODULE=on

WORKDIR /app

COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . . 
RUN go get -d -v ./graphTry 
RUN go install ./graphTry
RUN go build -o /go/bin/akew ./graphTry/server/server.go
# final stage
FROM alpine:3.7 as final
WORKDIR /usr/bin
COPY --from=build /go/bin .
EXPOSE 8080
CMD ["./akew"]

so the file which is the entry point to the program is “server” it is inside the

graphTry/server

when I try to build docker it returns an error

reading ./graphTry/server/server.go: unexpected NUL in input

what does it mean, one more thing my project not inside GOPATH, does it matter ?

This usually means that you have the byte 0x00 somewhere in the file. I doubt this is related to docker, can you build it on the host?

Yeah, I solved this issue but I faced another one now it returns

Step 13/15 : COPY --from=build /go/bin .
invalid from flag value build: pull access denied for build, repository does not exist or may require 'docker login'

and I am not using private repos

You named the first stage builder, not build.

1 Like

Oh God, thank you very much

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.