我一直在尝试为树莓派3上的python项目创建基本的ci / cd管道。我正在使用Jenkins构建Docker映像并将其推送到我的Dockerhub存储库中,但是在Jenkins期间遇到错误构建:
[91mstandard_init_linux.go:211: exec user process caused "exec format error"
我的Dockerfile如下
FROM arm32v7/python:3.7-slim-buster
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./main.py" ]
该问题发生在 RUN pip install 命令上,所以我认为Jenkins worker可能无法访问该文件。因此,我添加了一个额外的命令来更改权限:
FROM arm32v7/python:3.7-slim-buster
WORKDIR /usr/src/app
RUN chmod u=rwx,g=rx,o=rx requirements.txt
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./main.py" ]
Jenkins构建失败,并在 chmod 命令上出现相同的错误,并且由于所有/ bin / sh命令均失败,因此它似乎根本无法运行任何/ bin脚本。我以为是因为Jenkins无法指定某些命令,因为我在armv732中指定了构建?我目前在运行Ubuntu的计算机的本地主机上运行Jenkins。 我对Jenkins和Docker都非常陌生,所以我对系统如何工作的细节不熟悉。任何帮助将不胜感激。
Jenkins生成的日志:
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/jenkins-test-docker
using credential 719f731b-6c8d-4712-aa71-d9c221c23a9c
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/CoogyEoin/ev_mqtt_monitor.git # timeout=10
Fetching upstream changes from https://github.com/CoogyEoin/ev_mqtt_monitor.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials
> git fetch --tags --progress -- https://github.com/CoogyEoin/ev_mqtt_monitor.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/testBranch^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/testBranch^{commit} # timeout=10
Checking out Revision b4d0ed413636fd076e5fae1518062f0ae479fea7 (refs/remotes/origin/testBranch)
> git config core.sparsecheckout # timeout=10
> git checkout -f b4d0ed413636fd076e5fae1518062f0ae479fea7 # timeout=10
Commit message: "Seeing if chmod works"
> git rev-list --no-walk 7be754300f5003e54139b34a8f3dff7eecc4f5bf # timeout=10
[jenkins-test-docker] $ docker build -t coogy/ev_mqtt_monitor_test --pull=true /var/lib/jenkins/workspace/jenkins-test-docker
Sending build context to Docker daemon 216.1kB
Step 1/7 : FROM arm32v7/python:3.7-slim-buster
3.7-slim-buster: Pulling from arm32v7/python
Digest: sha256:0b115cbcf0c0a8164b2e486458af66418c78899a375750b9469c609c82c2cf36
Status: Image is up to date for arm32v7/python:3.7-slim-buster
---> 9a0c8b2b71f6
Step 2/7 : WORKDIR /usr/src/app
---> Using cache
---> 6f702979c25d
Step 3/7 : RUN chmod u=rwx,g=rx,o=rx requirements.txt
---> Running in c6a005a76880
[91mstandard_init_linux.go:211: exec user process caused "exec format error"
[0mThe command '/bin/sh -c chmod u=rwx,g=rx,o=rx requirements.txt' returned a non-zero code: 1
Build step 'Docker Build and Publish' marked build as failure
Finished: FAILURE
答案 0 :(得分:0)
您得到的错误表明该二进制文件是针对CPU体系结构而不是您在Jenkins中用作构建从属体系结构的。 Dockerfile中的大多数命令都是根据Dockerfile中指定的映像在容器内执行的,因此架构必须匹配。