将文件添加到泊坞窗映像会导致“权限被拒绝”。错误 [英] Adding a file to docker image results in "permission denied" error

查看:72
本文介绍了将文件添加到泊坞窗映像会导致“权限被拒绝”。错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建docker golang映像,但是我的golang应用程序需要在启动时读取config.yaml。我试图添加以下dockerfile中所示的文件:

I am creating a docker golang image, but my golang app needs to read a config.yaml on start. I tried to add the file as shown in the dockerfile below:

FROM golang:alpine as builder
# Install git + SSL ca certificates
RUN apk update && apk add git && apk add ca-certificates
# Create appuser
COPY . $GOPATH/src/github.com/user/app/
WORKDIR $GOPATH/src/github.com/user/app/
#get dependancies
RUN go get -d -v
#build the binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /go/bin/app
# STEP 2 build a small image
# start from scratch
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ADD ./config.yaml /go/bin/app/
# Copy our static executable
COPY --from=builder /go/bin/app /go/bin/app
EXPOSE 3000
ENTRYPOINT ["/go/bin/app"]

但出现以下错误:


docker:来自守护程序的错误响应:OCI运行时创建失败:container_linux.go:348:启动容器进程导致 exec:\ / go / bin / app\:权限被拒绝:未知。

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/go/bin/app\": permission denied": unknown.


推荐答案

问题在于执行 app ,请尝试在c之后 chmod + x 到/ go / bin / app

The problem is in the permission of execution of app, try to chmod +x to /go/bin/app after copying.

RUN chmod a+x /go/bin/app 

这篇关于将文件添加到泊坞窗映像会导致“权限被拒绝”。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆