Search code examples
dockergokubernetesgoogle-kubernetes-engine

Golang == Error: OCI runtime create failed: unable to start container process: exec: "./bin": stat ./bin: no such file or directory: unknown


I am trying to build this Dockerfile for Go Application and then deploy this to GKE but I'm seen this error upon pod creation. Upon describing this pod, I observed the same error.:

Error: failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./bin": stat ./bin: no such file or directory: unknown

This image successfully run locally using this command. docker run -it --rm bytecode01/domainalert:v2

#Dockerfile
FROM golang:alpine as builder
WORKDIR /data

COPY go.mod go.mod
RUN go mod download

# Copy the go source
COPY . .

# Build
RUN go build -a -o bin main.go

FROM alpine:latest

WORKDIR /data
COPY --from=builder /data/bin .
RUN chmod +x bin
CMD ["./bin"]

GKE PVC successfully mounted

#pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: de
  labels:
    name: de
spec:
  containers:
    - name: de-pod
      image: bytecode01/domainalert:v2
      imagePullPolicy: Always
      volumeMounts:
        - mountPath: /data
          name: app-volume
  volumes:
    - name: app-volume
      persistentVolumeClaim:
        claimName: pvc-dynamic
#pvc-dynamic.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-dynamic
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Mi
  storageClassName: standard

Help to get my issue solved.


Solution

  • Issue Solve

    There is an issue with the build command of the Go application. I'm now using this Dockerfile. and I've added GOARCH=amd64 to the command.

    FROM golang:latest AS build-stage
    
    WORKDIR /data
    COPY go.mod go.sum ./
    RUN go mod download
    
    COPY *.go ./
    
    RUN CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -o /domaintest
    
    FROM alpine:latest AS build-release-stage
    
    WORKDIR /data
    
    COPY --from=build-stage /domaintest /bin
    
    ENTRYPOINT ["/bin/domaintest"]