简体   繁体   中英

Running a docker Image of Golang failed, with error 'starting container process caused: exec: "/path": permission denied'

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM