簡體   English   中英

Docker: exec /usr/bin/sh: exec 格式錯誤

[英]Docker : exec /usr/bin/sh: exec format error

嗨,伙計們需要一些幫助。

我創建了一個自定義 docker 映像並將其推送到 docker 集線器,但是當我在 CI/CD 中運行它時,它給了我這個錯誤。

exec /usr/bin/sh: exec format error

在哪里:

Dockerfile

FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get install -y python3-pip
RUN pip3 install robotframework

.gitlab-ci.yml

robot-framework:
  image: rethkevin/rf:v1
  allow_failure: true
  script:
    - ls
    - pip3 --version

Output

Running with gitlab-runner 15.1.0 (76984217)
  on runner zgjy8gPC
Preparing the "docker" executor
Using Docker executor with image rethkevin/rf:v1 ...
Pulling docker image rethkevin/rf:v1 ...
Using docker image sha256:d2db066f04bd0c04f69db1622cd73b2fc2e78a5d95a68445618fe54b87f1d31f for rethkevin/rf:v1 with digest rethkevin/rf@sha256:58a500afcbd75ba477aa3076955967cebf66e2f69d4a5c1cca23d69f6775bf6a ...
Preparing environment
00:01
Running on runner-zgjy8gpc-project-1049-concurrent-0 via 1c8189df1d47...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/reth.bagares/test-rf/.git/
Checking out 339458a3 as main...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
Using docker image sha256:d2db066f04bd0c04f69db1622cd73b2fc2e78a5d95a68445618fe54b87f1d31f for rethkevin/rf:v1 with digest rethkevin/rf@sha256:58a500afcbd75ba477aa3076955967cebf66e2f69d4a5c1cca23d69f6775bf6a ...
exec /usr/bin/sh: exec format error
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

有什么想法可以解決這個錯誤嗎?

問題是你為 arm64/v8 構建了這個鏡像——但是你的跑步者使用了不同的架構。

如果你運行:

docker image inspect rethkevin/rf:v1

您將在 output 中看到這一點:

...
        "Architecture": "arm64",
        "Variant": "v8",
        "Os": "linux",
...

嘗試從您的 GitLab CI 運行器構建和推送您的圖像,以便圖像的架構與您的運行器的架構相匹配。

或者,您可以使用docker buildx 為多個架構構建 或者,您也可以在 ARM 架構上運行 GitLab 運行程序,以便它可以運行您構建它的架構的映像。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM