I am trying to create a dockerfile that uses a combination of rtlamr and rtlamr-collect to collect information about my utility meters. I cannot get the ENTRYPOINT
in docker to be rtlamr | rtlamr-collect
.
Here's my dockerfile
:
FROM golang:latest AS build
RUN CGO_ENABLED=0 GOOS=linux go install github.com/bemasher/rtlamr-collect@latest
RUN CGO_ENABLED=0 GOOS=linux go install github.com/bemasher/rtlamr@latest
# Use a multi-stage build to reduce our image size
FROM alpine:latest AS runtime
COPY --from=build /go/bin/rtlamr /usr/bin/rtlamr
COPY --from=build /go/bin/rtlamr-collect /usr/bin/rtlamr-collect
# Really wish this would just work as expected:
ENTRYPOINT ["rtlamr | rtlamr-collect"]
As a work around I have found that I can create a simple shell script and have that serve as the entry point, but that wasn't ideal because of the need for an extra file. I would not be opposed to a solution that somehow created the extra file on the fly however:
Working dockerfile
:
FROM golang:latest AS build
RUN CGO_ENABLED=0 GOOS=linux go install github.com/bemasher/rtlamr-collect@latest
RUN CGO_ENABLED=0 GOOS=linux go install github.com/bemasher/rtlamr@latest
# Use a multi-stage build to reduce our image size
FROM alpine:latest AS runtime
COPY --from=build /go/bin/rtlamr /usr/bin/rtlamr
COPY --from=build /go/bin/rtlamr-collect /usr/bin/rtlamr-collect
# I cannot for the life of me get `rtlamr | rtlamr-collect` to work as entry
# point to work around this limitation I created this small shell script that
# basically does it, and set that as the entry point which works.
ADD run.sh /usr/bin/run.sh
RUN chmod 777 /usr/bin/run.sh
ENTRYPOINT ["/usr/bin/run.sh"]
Content of run.sh
:
#!/bin/sh
rtlamr | rtlamr-collect
I believe a simple test case to play with might be something like this:
dockerfile
:
FROM alpine:latest
ENTRYPOINT ["echo 'hello world' | grep ell"]
Attempting to run this shows:
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "echo 'hello world' | grep ell": executable file not found in $PATH: unknown.
However if you login to the Docker Container Shell and perform the same command it works as expected:
/ # echo 'hello world' | grep ell
hello world