Dockerfile在本地计算机上编译但在docker hub中失败以进行自动构建

时间:2017-07-05 12:05:01

标签: docker dockerfile raspberry-pi3 dockerhub alpine

我试图通过链接包含Dockerfile的github repo来在docker hub中创建一个自动构建docker镜像。此图像适用于Raspberry Pi 3(可在Dockerfile中看到)。虽然Dockerfile在 Raspberry Pi 中运行良好,但它在 x86_64 GNU / Linux 机器以及 Docker hub 中出错,但无法编译。这是来自Docker hub的日志。 docker hub和x86_64 GNU / Linux机器中的最终错误相同。

Building in Docker Cloud's infrastructure...
Cloning into '.'...
KernelVersion: 4.4.0-79-generic
Arch: amd64
BuildTime: 2017-03-28T19:26:53.326478373+00:00
ApiVersion: 1.27
Version: 17.03.1-ee-2
MinAPIVersion: 1.12
GitCommit: ad495cb
Os: linux
GoVersion: go1.7.5
Starting build of index.docker.io/swapnil18/docker-swarm-arm-socat:latest...
Step 1/11 : FROM resin/raspberrypi3-alpine

 ---> ca84ecc9fee4

Step 2/11 : MAINTAINER Swapnil Das <dasswapnil96@gmail.com>

 ---> Running in 2a99be7f728e

 ---> e4c7fdd1bc5b

Removing intermediate container 2a99be7f728e

Step 3/11 : ARG "version=0.1.0-dev"

 ---> Running in 1019fe4333d4

 ---> d50c71235386

Removing intermediate container 1019fe4333d4

Step 4/11 : ARG "build_date=5/7/17"

 ---> Running in cbf271f27274

 ---> c9af4b356b3c

Removing intermediate container cbf271f27274

Step 5/11 : ARG "commit_hash=unknown"

 ---> Running in 1778288bf297

 ---> 35d52f36b527

Removing intermediate container 1778288bf297

Step 6/11 : ARG "vcs_url=unknown"

 ---> Running in db86bc110c3d

 ---> 9062830e7754

Removing intermediate container db86bc110c3d

Step 7/11 : ARG "vcs_branch=unknown"

 ---> Running in 919c08a0f584

 ---> 9532842acc1b

Removing intermediate container 919c08a0f584

Step 8/11 : LABEL org.label-schema.vendor "Personal" org.label-schema.name "Socat" org.label-schema.description "Exposes to a defined OUTPUT PORT the INPUT from a TCP endpoint." org.label-schema.usage "/src/README.md" org.label-schema.url "https://github.com/swapnil96/docker-swarm-arm-socat/blob/master/README.md" org.label-schema.vcs-url $vcs_url org.label-schema.vcs-branch $vcs_branch org.label-schema.vcs-ref $commit_hash org.label-schema.version $version org.label-schema.schema-version "1.0" org.label-schema.docker.cmd.devel "" org.label-schema.docker.params "IN=Input,OUT=Output" org.label-schema.build-date $build_date

 ---> Running in 641e40ae7219

 ---> 9c5d5da14397

Removing intermediate container 641e40ae7219

Step 9/11 : ENV "IN 172.18.0.1:4999" "OUT 4999"

 ---> Running in 866b338a1588

 ---> 3c046f12eb1e

Removing intermediate container 866b338a1588

Step 10/11 : RUN apk add --no-cache socat

 ---> Running in 86d0de61864f

[91mstandard_init_linux.go:178: exec user process caused "exec format error"
[0m
Removing intermediate container 86d0de61864f

The command '/bin/sh -c apk add --no-cache socat' returned a non-zero code: 1

从最后一点可以看出它失败了The command '/bin/sh -c apk add --no-cache socat' returned a non-zero code: 1。 Dockerfile是否存在一些架构问题?或者基础图像存在树脂/高山的问题。我为Raspberry Pi构建了其他Dockerfiles,所有编译都很好。

出于工作目的,我将推送Raspberry Pi中内置的图像。但拥有自动构建存储库要好得多。如果我做了一些明显的错误,请纠正我。

以下是我在docker hub link中的其他版本的链接。

PS:我已经尝试过stackoverflow中提到的其他选项。我试图发布其他问题的链接,但由于声誉不到10,我只发布了2个链接。

1 个答案:

答案 0 :(得分:1)

这是因为 Raspberry Pi arm 上运行,而docker hub不支持 arm x86 ,如果您希望在docker hub上构建docker镜像,则需要对docker镜像进行编辑。我之前已经这样做了,但它已经很老了,但请查看resin io's work或我自己的定制,而不是here。此方法使用qemu模拟 arm 体系结构,允许图像在 arm 设备上本机运行,例如 Raspberry Pi ,同时仍然可以通过qemu在 x86 平台上,如docker hub。