I have been working a lot with Docker and Go lately and I come across a very annoying error when running tools built in Go in containers on a RaspberryPi. All of the bug reports I found had something to do with Windows-style line endings (CRLF) but I am using MacOS, so this can’t be the solution (at least) for me here.

This is the Dockerfile I have been using:

FROM alpine
ADD washing-machine /app/washing-machine
CMD ["./washing-machine"]

Turns out building the binary on the mac doesn’t work, even using GOOS and GOARCH didn’t do the trick, so I now build the binary in the container, using the golang image from Docker hub:

FROM golang:1.9.3-alpine3.7
ADD . /app
RUN cd /app && \
    apk update && \
    apk add git bash && \
    go get github.com/domnikl/ifttt-webhook && \
    go get github.com/domnikl/fritz-box && \
    go build -o washing-machine
CMD [ "/app/washing-machine" ]

Hope this will help you in getting around this annoying error message.