3

As the title said, I cannot reproduce this kind of error in any Dockerfiles of mine, after trying to run the Docker Container with

docker run registryName:tag

I'm trying to cross compile from amd64 -> arm6 via gitLab CI

1. Dockerfile:

FROM golang:1.10.2-alpine as builder
WORKDIR /go/src/.../.../dht22
COPY . .
RUN apk add --no-cache alpine-sdk  \
    && go get ./... \
    && GOOS=linux CGO_ENABLED=1 go build -a -o app .

FROM arm32v6/alpine:latest
COPY --from=builder /go/src/.../.../dht22/app /app
ENTRYPOINT ["/app"]

2. Dockerfile.arm6 to Cross Compile and run Golang binary on Raspberry Pi:

FROM golang:1.10.2 as builder
WORKDIR /go/src/.../.../dht22
COPY . .
RUN go tool dist list | grep arm \
    && apt-get update \
    && apt-get install -y build-essential gcc-arm-linux-gnueabi \
    && go get ./... \
    && CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -a -o app .

FROM arm32v6/alpine:latest
COPY --from=builder /go/src/.../.../dht22/app /app
ENTRYPOINT ["/app"]

What I have tried so far

  • Adding !#bin/bash || !#bin/sh

  • Reinstall Docker

  • CGO_ENABLED=0 isn`t an option cause my Golang dht22 Project has C dependencies

Dockerinfo from Raspberry where my container should run:

Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   ....
 Built:        Thu May  4 22:30:54 2017
 OS/Arch:      linux/arm

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   ....
 Built:        Thu May  4 22:30:54 2017
 OS/Arch:      linux/arm
 Experimental: false
  • Why do I have this error message?

Edit:

  • A simple Hello World does work in a container with those configs (with 0 dependencies, only "fmt" as package).

  • My golang project has a third library dependency (https://github.com/d2r2/go-dht) I suspect this throws the error causes of missing dependencies during the build.

  • Instead of Cross Compiling , Ive build my Image with the 1st Dockerfile on my Raspberry pi (arm).Container runs about 3h and then exites with Code: 139

Phong
  • 113
  • 1
  • 10

2 Answers2

1

My Problem is fixed. Reason was GCC Compiler plus Alpine in addition. I turned my back to alpine and switched to

resin/arm7hf-debian

as Base Image. Alpine missed a lib3 directory (Probably a System Library) which was the reason why Docker exits with a error Code 190 no such file or directory

Here is my new Dockerfile:

FROM golang:1.10.3 as builder
WORKDIR /go/src/git/name/dht22
COPY . .
RUN go tool dist list | grep arm \
   && apt-get update \
   && apt-get install -y build-essential gcc-arm-linux-gnueabi \
   && go get ./... \
   && CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm 
      GOARM=6 go build -a -o dht22binary dht22.go

FROM resin/armv7hf-debian
WORKDIR /go/src/git/name/dht22
COPY --from=builder /go/src/git/name/dht22 /dht22binary
ENTRYPOINT ['./dht22binary']

For all those who are trying to building on a alpine with CGO_ENABLED=1. Just use Debian instead of Alpine as base Image

Edit note:

  • For Raspberry PI 3 user take FROM resin/raspberrypi3-debian as Base Image
  • To run Your Container with those Docker configs use following Command:

    docker run --privileged -d yourimage

Important: --privileged -d (in a nutshell) grants your Docker Container GPIO Access

Image Size: 22.56 MiB

Phong
  • 113
  • 1
  • 10
0

Your cross-compilation seems erroneous. You should replace alpine:latest to arm32v6/alpine:latest in your Dockerfile.arm6 file and recompile your image