![](/img/trans.png)
[英]Why does Docker “give executable file `/bin/sh` not found in $PATH”?
[英]Why does my GitLab build fail with error: “executable file not found in $PATH”
我在構建中反復收到以下錯誤
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)
簡化為最簡單的我有以下.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
經過大量搜索,重新啟動服務,清除緩存和頭撞,結果證明這是我的愚蠢。 GitLab 甚至告訴我錯誤 output 中的問題是什么。 我正在設置PATH
變量,這是系統用來知道在哪里查找可執行文件的變量,所以我的更改導致它失去了找到自己的可執行文件的能力。
在 yaml 中將PATH
重命名為BUILD_PATH
將其修復為 100%。
我添加了這個,因為我在搜索時找不到任何參考。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.