英文:
How to reslove permission denied while building docker compose
问题
我正在尝试构建以下Docker文件并运行它,但是我遇到了这个错误:
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./doc8": permission denied: unknown
我的Docker文件如下,尝试构建两个容器,一个是Go,另一个是PostgreSQL:
version: '3.7'
services:
postgre-db:
container_name: postgre-db
image: postgres:12.2-alpine
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
doc8server:
container_name: doc8server
image: {IMAGE_NAME}
env_file:
- doc8.env
build:
context: .
dockerfile: Dockerfile.doc8server.multistage
ports:
- "{PORT}:{PORT}"
volumes:
- doc8data:/opt/app/assets/pdfs
- doc8data:/opt/app/assets/pdfs/originalFiles
depends_on:
- postgre-db
volumes:
pgdata: {}
doc8data: {}
这是我的运行命令:
docker compose up -d
这是我的Dockerfile:
FROM golang:latest as builder
LABEL maintainer="Doc8 <example@gmail.com>"
WORKDIR /app/invos_server_golang
COPY go.mod go.sum ./
RUN go mod download
COPY . .
WORKDIR /app/invos_server_golang
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o doc8 .
FROM rastasheep/ubuntu-sshd:latest
WORKDIR /opt/app
COPY --from=builder /app/invos_server_golang/doc8 .
COPY --from=builder /app/invos_server_golang/doc8.env .
EXPOSE {PORT}
CMD ["./doc8"]
请告诉我是否有任何错误。
英文:
I am trying to build following docker file and then run it but I'm getting this error
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./doc8": permission denied: unknown
My docker file is as follows in that trying to build two containers one go and another id PostgreSQL:
version: '3.7'
services:
postgre-db:
container_name: postgre-db
image: postgres:12.2-alpine
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
doc8server:
container_name: doc8server
image: {IMAGE_NAME}
env_file:
- doc8.env
build:
context: .
dockerfile: Dockerfile.doc8server.multistage
ports:
- "{PORT}:{PORT}"
volumes:
- doc8data:/opt/app/assets/pdfs
- doc8data:/opt/app/assets/pdfs/originalFiles
depends_on:
- postgre-db
volumes:
pgdata: {}
doc8data: {}
this my run command
docker compose up -d
And this my dockerfile
FROM golang:latest as builder
LABEL maintainer="Doc8 <example@gmail.com>"
WORKDIR /app/invos_server_golang
COPY go.mod go.sum ./
RUN go mod download
COPY . .
WORKDIR /app/invos_server_golang
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o doc8 .
FROM rastasheep/ubuntu-sshd:latest
WORKDIR /opt/app
COPY --from=builder /app/invos_server_golang/doc8 .
COPY --from=builder /app/invos_server_golang/doc8.env .
EXPOSE {PORT}
CMD ["./doc8"]
Please let me know if I am doing anything wrong
答案1
得分: 1
似乎在容器内执行"./doc8"命令时出现了权限问题。您可以修改Dockerfile,在运行之前确保可执行文件具有正确的权限。
在Dockerfile中进行以下修改:
# 添加可执行权限到可执行文件
RUN chmod +x ./doc8
CMD ["./doc8"]
英文:
It seems there is a permission issue when trying to execute the ./doc8 command within the container. You can modify the docker file to ensure the executable has the correct permissions before running it.
MODIFY THIS IN THE DOCKERFILE:
# Add execute permissions to the executable
RUN chmod +x ./doc8
CMD ["./doc8"]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论