Search code examples
dockergodockerfilegitlab-cigitlab-ci-runner

Gitlab Runner error exec: "sh": executable file not found in $PATH


I have this error when running a container on Gitlab CI

ERROR: Job failed (system failure): Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "sh": executable file not found in $PATH: unknown (exec.go:57:0s)

My .Dockerfile

FROM golang:1.16-alpine AS builder
ENV \
    OUTDIR='/out' \
    GO111MODULE='on'    

WORKDIR /app
COPY go.mod /app/
COPY go.sum /app/
RUN go mod download
COPY . /app/
RUN CGO_ENABLED=0 GOBIN=${OUTDIR}/usr/bin/ go install .

FROM scratch
COPY --from=builder /out/ /
ENTRYPOINT ["/usr/bin/app-cli"]

My .gitlab-ci.yml

stages:
  - validation

validation:
  image:
    name: gitlab.mycompany.net:4567/myteam/app-cli:latest
    entrypoint: [""]
  stage: validation
  rules:
    - if: '$CI_MERGE_REQUEST_IID'
  script:
    - ls

Is this error related to my dockerfile or the gitlab ci ?

I can run this locally by docker run --rm -ti gitlab.mycompany.net:4567/myteam/app-cli:latest but not at gitlab runner


Solution

  • found the answer

    I just need to change the FROM scratch to FROM alpine:latest so now I can use the sh