buildkit · Docker
報錯原文
failed to solve: process "/bin/sh -c npm ci" did not complete successfully: exit code: 1
這是什麼意思
Dockerfile 裡那條 RUN 以非零狀態結束了。這一行帶的只有「哪條命令失敗、結束碼是幾」,真正的原因在它上面那條命令自己的輸出裡,而 BuildKit 一旦某步結束就傾向於把它摺疊起來。用 docker build --progress=plain 重跑,會把每一步的輸出完整印出來;如果是某個快取層藏住了更早的失敗,再加 --no-cache——代價是從第一步開始整個重建。exit code: 1 不是原因,只是「這條命令失敗了」這個事實。
怎麼修
docker build --progress=plain --no-cache .- 來自
- buildkit
- Docker
- 12
docker 的錯誤要先歸到某一層才讀得懂——用戶端連不上守護行程、映像檔倉庫拒絕你、建置過程中某條 RUN 失敗、容器一起來就死掉,是四種不同的問題——而在建置和執行這兩層,那行字本身並不是原因:原因在裡面那條命令留下的輸出裡,各層修復的代價也不一樣。
怎麼讀報錯
- 從第一行往下讀。越往下越是工具內部的事,起因通常寫在最上面。
- 有檔名和行號就從那裡查——不是堆疊最上面那一格,而是最上面那條提到你自己寫的檔案的行。
- 把報錯原文照樣去搜,但先去掉你自己的路徑和變數名,正是那些讓搜尋比對不上。
- 同一種情況在不同版本裡措辭不同。結果不對頭,就把版本號一起加進查詢。
- 貼上修法之前,先確認它會丟掉什麼。這裡面有些是不能收回的。
常見問題
Q. “failed to solve: process "/bin/sh -c npm ci" did not complete successfully: exit code: 1” 是什麼意思?
Dockerfile 裡那條 RUN 以非零狀態結束了。這一行帶的只有「哪條命令失敗、結束碼是幾」,真正的原因在它上面那條命令自己的輸出裡,而 BuildKit 一旦某步結束就傾向於把它摺疊起來。用 docker build --progress=plain 重跑,會把每一步的輸出完整印出來;如果是某個快取層藏住了更早的失敗,再加 --no-cache——代價是從第一步開始整個重建。exit code: 1 不是原因,只是「這條命令失敗了」這個事實。
Q. 怎麼修?
docker build --progress=plain --no-cache . —— 執行前先看上面的說明,確認這條命令會丟掉什麼。
Q. 這是哪個工具報的?
buildkit。它屬於Docker,報錯原文有 15 個詞。
相關報錯
COPY failed: file not found in build context or excluded by .dockerignoredockerfailed to register layer: Error processing tar file(exit status 1): no space left on devicedockerexec /usr/local/bin/entrypoint.sh: exec format errordockerstandard_init_linux.go: exec user process caused: no such file or directoryruncOCI runtime create failed: exec: "bash": executable file not found in $PATH: unknownruncCannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?dockerBind for 0.0.0.0:8080 failed: port is already allocateddockerConflict. The container name "/api" is already in use by containerdocker