hasnat / docker-events-notifier

Docker events notifier
MIT License
9 stars 1 forks source link

Container does not start #7

Open Tecnomiky opened 7 months ago

Tecnomiky commented 7 months ago

Hello,

I configured the container on a Raspberry Pi 4B with Debian GNU/Linux 12 (bookworm) and Docker 25.03 as operating system.

The problem I report is that it does not start displaying the following error "exec ./docker-events-notifier: exec format error" .

I checked the config file with a yaml validator and there are no errors.

What's the problem?

Thanks for the help.

hasnat commented 7 months ago

Could be image built on docker hub isn’t raspberry pi architecture compatible. You could try building it yourself. Building directly on pi would ensure right compatibility. Or you can build remotely via build buildkit. Unsure if go build command in dockerfile would need changes.  Also double check docker api version env variable. That has to match the version your docker host supports. ‘docker info’ and some info on readme. I don’t have raspberries to try on. Regards,HasnatOn Feb 10, 2024, at 15:28, Michele Giorgio @.***> wrote: Hello, I configured the container on a Raspberry Pi 4B with Debian GNU/Linux 12 (bookworm) and Docker 25.03 as operating system. The problem I report is that it does not start displaying the following error "exec ./docker-events-notifier: exec format error" . I checked the config file with a yaml validator and there are no errors. What's the problem? Thanks for the help.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

Tecnomiky commented 7 months ago

Thanks for the reply.

I've never programmed in go so I don't know how the build process works. I created the go folder inside my home folder and set the GOPATH environment variable as follows export GOPATH=$HOME/go and modified the Dockerfile as follows

FROM golang:1.15 as builder

WORKDIR $GOPATH/docker-events-notifier

COPY main.go .

RUN go get -d -v ./...

RUN go install -v ./...

ENV DOCKER_API_VERSION=1.43
ENV RLOG_LOG_LEVEL=WARN
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /go/bin/docker-events-notifier .

FROM alpine:latest

WORKDIR /etc/docker-events-notifier

COPY templates/ /etc/docker-events-notifier/templates/
COPY --from=builder /go/bin/docker-events-notifier .

When I run the command sudo docker-compose up --build I get the following error

go install: no install location for directory /go outside GOPATH
         For more details see: 'go help gopath'
The command '/bin/sh -c go install -v ./...' returned a non-zero code: 1
ERROR: Service 'docker-events-notifier' failed to build : Build failed

How can I solve it?

hasnat commented 7 months ago

not a go lang or build expert myself, however did you try keeping the workdir line same?

I think you might be missing only src before the name. Try like so if keeping the line as-is is troublesome.

WORKDIR $GOPATH/src/docker-events-notifier

btw any exports you do in your cli don't get automatically reflected in docker-compose build and if envs set in docker-compose file, will only apply to runtime not buildtime. for envs in build stage, you'll have to use lines like ENV blabla=123 in Dockerfile. exports I think only get applied for one RUN line (when using RUN export... instead of ENV ... in Dockerfile).

hasnat commented 7 months ago

@Tecnomiky I tried it on a rasberry pi, and all worked ok straight from docker hub build + runtime were also both ok

docker info

 Kernel Version: 6.1.21-v7+
 Operating System: Raspbian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: armv7l
 CPUs: 4
 Total Memory: 922MiB

Docker API version curl --silent --unix-socket /var/run/docker.sock http://x/version gives me 1.44 API version

{"Platform":{"Name":"Docker Engine - Community"},"Components":[{"Name":"Engine","Version":"25.0.3","Details":{"ApiVersion":"1.44","Arch":"arm","BuildTime":"2024-02-06T21:21:34.000000000+00:00","Experimental":"false","GitCommit":"f417435","GoVersion":"go1.21.6","KernelVersion":"6.1.21-v7+","MinAPIVersion":"1.24","Os":"linux"}},{"Name":"containerd","Version":"1.6.28","Details":{"GitCommit":"ae07eda36dd25f8a1b98dfbf587313b99c0190bb"}},{"Name":"runc","Version":"1.1.12","Details":{"GitCommit":"v1.1.12-0-g51d5e94"}},{"Name":"docker-init","Version":"0.19.0","Details":{"GitCommit":"de40ad0"}}],"Version":"25.0.3","ApiVersion":"1.44","MinAPIVersion":"1.24","GitCommit":"f417435","GoVersion":"go1.21.6","Os":"linux","Arch":"arm","KernelVersion":"6.1.21-v7+","BuildTime":"2024-02-06T21:21:34.000000000+00:00"}