0
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
  • 1
    did you check whether docker daemon is running? also verify whether you have permissions to execute docker. – Mani Oct 06 '20 at 02:03
  • @Mani OK, So the Docker Desktop wasn't running. –  Oct 06 '20 at 02:30
  • Make sure there are no other programs using the files. Check this https://stackoverflow.com/questions/46971182/on-building-docker-image-level-error-msg-cant-close-tar-writer-io-read-write – Gowtham Munukutla Oct 06 '20 at 05:26

1 Answers1

0

@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 . . above the go mod download call, and removing both COPY go.mod . and COPY go.sum .

RuNpiXelruN
  • 1,850
  • 2
  • 17
  • 23