猿问

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


一只名叫tom的猫
浏览 179回答 1
1回答

蝴蝶刀刀

只要确保你的代码包含package main
随时随地看视频慕课网APP

相关分类

Go
我要回答