简体   繁体   中英

Issues with building Dockerfile

RUN mkdir /app
WORKDIR /app

# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .

RUN go mod download

COPY . .

# Build the Go app
RUN go build -o ./out/go-sample-app .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o main app/server.go

# This container exposes port 8080 to the outside world
EXPOSE 8080

# Run the binary program produced by `go install`
CMD ["go", "run, "server.go"]

The error which I am getting is this. So I've been trying to write a Dockerfile for the first time for my Golang App and this is the issue I am running into.

time="2020-10-06T07:03:55+05:30" level=error msg="Can't add file \\\\?\\D:\\0 NAT IT\\DumGo\\.git\\hooks\\update.sample to tar: io: read/write on closed pipe"
time="2020-10-06T07:03:55+05:30" level=error msg="Can't close tar writer: io: read/write on closed pipe"
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=zuyf430dft91rrte7rvtw9kjg&shmsize=0&target=&ulimits=null&version=1: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

The file structure is like

~DumGo
   /graph
Dockerfile
go.mod
go.sum
server.go

@divan_cyph make sure you have docker running. You can check by executing docker info from your cli.

Side note, you can save a couple of lines by just adding your COPY . . COPY . . above the go mod download call, and removing both COPY go.mod . and COPY go.sum .

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