I build a Go
docker image from docker file successfully, but docker run -p port:port --name imagename imageid
gives me permission denied
error.
This is my docker file
FROM golang:1.17.2-alpine3.13 as build
WORKDIR /app
COPY . .
RUN go build -o app
FROM alpine:3.7
COPY --from=build /app /usr/local/bin/go_webhooks
RUN chmod x /usr/local/bin/go_webhooks
ENTRYPOINT ["/usr/local/bin/go_webhooks"]
I tried using chmod
but still could not solve it.
The actual error message is:
docker run -p 8000:8000 --name go_webs3 d5f30e8f9703
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:380: starting container process caused: exec:
"/usr/local/bin/go_webhooks": permission denied: unknown.
ERRO[0000] error waiting for container: context canceled
CodePudding user response:
A past similar error message pointed out to a go build
issue.
But in your case, copying a folder to /usr/local/bin/go_webhooks
would make go_webhooks
a folder.
WORKDIR /app
# means /app is a folder
You cannot directly execute a folder.
Your Entrypoint needs to reference an executable inside that folder.
You might needs to copy the built file inside /app:
COPY --from=build /app/app /usr/local/bin/go_webhooks