George
George

Reputation: 2960

Why does my GitLab build fail with error: "executable file not found in $PATH"

I am getting the following error repeatedly on a build

Running with gitlab-runner 13.8.0 (775dd39d)
  on docker+machine ABwVypz2
Preparing the "docker+machine" executor
00:16
Using Docker executor with image docker:latest ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Using docker image sha256:6e82c575b16fb92f31c77a6ba88cadffa1720acd6e33526d82814232a82eb780 for docker:dind with digest docker@sha256:9f9a930bc5ec2e000867a87de844cae04590bafe929340e2fae4cb959cf6bc8f ...
ERROR: Preparation failed: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "dockerd-entrypoint.sh": executable file not found in $PATH: unknown (docker.go:502:0s)
Will be retried in 3s ...
Using Docker executor with image docker:latest ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Using docker image sha256:6e82c575b16fb92f31c77a6ba88cadffa1720acd6e33526d82814232a82eb780 for docker:dind with digest docker@sha256:9f9a930bc5ec2e000867a87de844cae04590bafe929340e2fae4cb959cf6bc8f ...
ERROR: Preparation failed: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "dockerd-entrypoint.sh": executable file not found in $PATH: unknown (docker.go:502:0s)
Will be retried in 3s ...
Using Docker executor with image docker:latest ...
Starting service docker:dind ...
Pulling docker image docker:dind ...
Using docker image sha256:6e82c575b16fb92f31c77a6ba88cadffa1720acd6e33526d82814232a82eb780 for docker:dind with digest docker@sha256:9f9a930bc5ec2e000867a87de844cae04590bafe929340e2fae4cb959cf6bc8f ...
ERROR: Preparation failed: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "dockerd-entrypoint.sh": executable file not found in $PATH: unknown (docker.go:502:0s)
Will be retried in 3s ...
ERROR: Job failed (system failure): Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "dockerd-entrypoint.sh": executable file not found in $PATH: unknown (docker.go:502:0s)

Reduced to it's simplest I have the following .gitlab-ci.yaml

image: docker:latest
services:
    - docker:dind

stages:
    - build

.build-image:
    stage: build
    script:
        - docker build ${TAG} ${BUILD_ARGS} -f ${PATH}/${DOCKERFILE} ${PATH}

build-legacy-php:
    extends: .build-image
    parallel:
        matrix:
            - PHP_VERSION: ['5.6', '7.2']
    variables:
        BUILD_ARGS: --build-arg PHP_VERSION=${PHP_VERSION}
        PATH: php
        DOCKERFILE: Dockerfile.legacy
        TAG: php:$PHP_VERSION-latest

Upvotes: 0

Views: 2945

Answers (1)

George
George

Reputation: 2960

After much searching, restarting services, clearing caches and headbanging this turned out to be my stupidity. GitLab was even telling me what the issue was in the error output. I was setting the PATH variable which is what the system uses to know where to look for executables so my change caused it to lose the ability to find it's own executables.

Renaming PATH to BUILD_PATH in the yaml fixed it 100%.

I added this because I couldn't find any reference when I was searching.

Upvotes: 2

Related Questions