Golang Dockerfile权限被拒绝



我似乎有一个错误的权限分布在我的Dockerfile,我似乎无法解决它。

这里是错误

Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/my-app": permission denied: unknown

这是我的Dockerfile

# syntax=docker/dockerfile:1
##
## Build
##
FROM golang:1.19rc2-buster AS build
WORKDIR /app
COPY src/go.mod ./
COPY src/go.sum ./
RUN go mod download
COPY src/*.go ./
RUN go build -o /my-app
##
## Deploy
##
FROM gcr.io/distroless/base-debian10
WORKDIR /
COPY --from=build /my-app /my-app
USER nonroot:nonroot
ENTRYPOINT ["/my-app"]

这是我的docker-compose

version: "3.7"
services:
golang:
container_name: golang
build:
dockerfile: go.Dockerfile
ports:
- 8080:80
depends_on:
- cassandra
restart: always
cassandra:
container_name: cassandra
image: cassandra:latest
restart: always
ports:
- 9042:9042

只要确保你的go代码包含

package main

相关内容

  • 没有找到相关文章

最新更新