Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container does not start #7

Open
Tecnomiky opened this issue Feb 10, 2024 · 4 comments
Open

Container does not start #7

Tecnomiky opened this issue Feb 10, 2024 · 4 comments

Comments

@Tecnomiky
Copy link

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
Copy link
Owner

hasnat commented Feb 10, 2024 via email

@Tecnomiky
Copy link
Author

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
Copy link
Owner

hasnat commented Feb 11, 2024

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
Copy link
Owner

hasnat commented Feb 19, 2024

@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"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants