用于Arm / Arm64的DockerHub自动化构建-权限被拒绝

时间:2019-04-23 20:19:46

标签: build arm dockerfile arm64 dockerhub

在本地PC上运行的构建过程在DockerHub上以自动构建形式运行时出现错误。

链接到我尝试使用自动ARM构建的分支:https://github.com/psyciknz/ParadoxIP150v2/tree/homie-and-events

AMD64的构建在DockerHub上运行良好。

跟随:How to build a Docker image on a specific architecture with Docker Hub?

按照上面的链接,成功解决了下载正确的qemu的问题(我尝试过x86_64-qemu-arm-static和qemu-arm-static),成功解决了我遇到的所有问题主源目录中没有docker文件(我使用以下结构):

/
  applicationcode.py
  Docker
    Dockerfile
    Dockerfile.arm32v7
    Dockerfile.arm64v8
    hooks
       build
       post_checkout
       pre_build

现在,我当前的问题是在docker文件中它发布了:

RUN pip install paho-mqtt requests 

在DockerHub构建日志中,我得到:

Status: Downloaded newer image for arm32v7/python:2.7.15-jessie
---> a0873323b42b
Step 2/12 : COPY qemu-arm-static /usr/bin/
---> 49f090a8faac
Step 3/12 : RUN pip install paho-mqtt requests
---> Running in 2d6bb52d61bd
standard_init_linux.go:190: exec user process caused "permission denied"
The command '/bin/sh -c pip install paho-mqtt requests' returned a non-zero code: 1
build hook failed! (1)

构建钩子在哪里:

#!/bin/bash

# Get the name of the docker file (without path)
BUILD_FILE=$(echo Docker/Dockerfile.arm32v7 | cut -d '/' -f 2)

echo 'starting build'
echo ${DOCKERFILE_PATH}
echo ${BUILD_FILE}
echo ${IMAGE_NAME}
docker build \
    -f "${DOCKERFILE_PATH}" \
    -t "${IMAGE_NAME}" \
    .

这是一个简单的构建命令。即使没有这个,我也会遇到同样的错误。

这里是post_checkout:

#!/bin/bash

BUILD_ARCH=$(echo "${DOCKERFILE_PATH}" | cut -d '.' -f 2)
echo ${BUILD_ARCH}

[ "${BUILD_ARCH}" == "Dockerfile" ] && 
    { echo 'qemu-user-static: Download not required for current arch'; exit 0; }
if [ "${BUILD_ARCH}" == "arm64v8" ]; then
    echo 'arm64'
    QEMU_USER_STATIC_ARCH=$([ "${BUILD_ARCH}" == "arm64v8" ] && echo "aarch64" || echo "${BUILD_ARCH}")
else
    QEMU_USER_STATIC_ARCH=$([ "${BUILD_ARCH}" == "arm32v7" ] && echo "${BUILD_ARCH::-4}" || echo "${BUILD_ARCH}")
    echo 'arm'
fi
QEMU_USER_STATIC_DOWNLOAD_URL="https://github.com/multiarch/qemu-user-static/releases/download"
QEMU_USER_STATIC_LATEST_TAG=$(curl -s https://api.github.com/repos/multiarch/qemu-user-static/tags | grep 'name.*v[0-9]' | head -n 1 | cut -d '"' -f 4)
curl -SL "${QEMU_USER_STATIC_DOWNLOAD_URL}/${QEMU_USER_STATIC_LATEST_TAG}/qemu-${QEMU_USER_STATIC_ARCH}-static" -o "qemu-${QEMU_USER_STATIC_ARCH}-static"
echo 'Directory (should be Docker)'
pwd
ls -la
echo 'Default uname'
uname -a

我添加了一些额外的命令来帮助确定我在文件系统中的位置并获取文件列表。

预构建:

#!/bin/bash

BUILD_ARCH=$(echo "${DOCKERFILE_PATH}" | cut -d '.' -f 2)

[ "${BUILD_ARCH}" == "Dockerfile" ] && 
    { echo 'qemu-user-static: Registration not required for current arch'; exit 0; }

docker run --rm --privileged multiarch/qemu-user-static:register --reset

Arm32 DockerFile。

FROM arm32v7/python:2.7.15-jessie

#copy qemu from Docker/hooks (when on DockerHub)
COPY qemu-arm-static /usr/bin/

# based on https://github.com/pfichtner/docker-mqttwarn

# install python libraries (TODO: any others?)
RUN pip install paho-mqtt requests 

# build /opt/mqttwarn
RUN mkdir -p /opt/paradox
WORKDIR /opt/paradox

# add user mqttwarn to image
RUN groupadd -r paradox && useradd -r -g paradox paradox
RUN chown -R paradox /opt/paradox

# process run as mqttwarn user
USER paradox

# conf file from host
VOLUME ["/opt/paradox/conf"]

# set conf path
ENV PARADOXINI="/opt/paradox/conf/config.ini"

# finally, copy the current code (ideally we'd copy only what we need, but it
#  is not clear what that is, yet)
COPY . /opt/paradox

# run process
CMD python IP150MQTTv2.py

但是,如果我在Ubuntu机器上运行相同的docker文件(具有相同的qemu文件)。 sudo docker build -f Docker/Dockerfile.arm32v7 . 我得到一个构建。据我所知,该过程有效,但是我仍然遇到了有关do​​cker hub环境的事情。

0 个答案:

没有答案
相关问题