docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process

huangapple go评论214阅读模式
英文:

docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process

问题

我正在尝试构建这个 Dockerfile 并运行它,但是我遇到了这个错误:docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./deployment-service": permission denied: unknown.

这是我的 Dockerfile,我已经创建了卷和网络:

FROM golang:1.19.2-alpine as builder

RUN apk add bash

RUN apk add --no-cache openssh-client ansible git

RUN mkdir /workspace
WORKDIR /workspace

COPY go.mod ./
COPY go.sum ./

RUN go mod download

COPY . ./

RUN go build -o deployment-service cmd/deployment-service/main.go

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/

COPY --from=builder /workspace .

ARG DEFAULT_PORT=8080
ENV PORT $DEFAULT_PORT

EXPOSE $PORT

CMD ["./deployment-service"]

这是我的运行命令:

docker run --name=${CONTAINER_NAME} -d --rm -p ${PORT}:80 -e DEPLOYMENT_SERVICE_DATABASE_CONNECTION_URI=mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_CONTAINER_NAME}:27017/ -e DEPLOYMENT_SERVICE_SERVER_SECRET_KEY=${SECRET_KEY} -e ANSIBLE_CONFIG='./jam-ansible/ansible.cfg' -e DEPLOYMENT_SERVICE_ANSIBLE_SUBMISSION_ROOT=${DEPLOYMENT_ROOT} -v ${DEPLOYMENT_VOLUME}:${DEPLOYMENT_ROOT} --network=${NETWORK_NAME} server:latest

帮助解决我的问题。

英文:

I am trying to build this dockerfile and then run it but I'm getting this error docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "./deployment-service": permission denied: unknown.

This is my docker file, I've created the volumes and networks

FROM golang:1.19.2-alpine as builder

RUN apk add bash

RUN apk add --no-cache openssh-client ansible git

RUN mkdir /workspace
WORKDIR /workspace

COPY go.mod ./
COPY go.sum ./

RUN go mod download

COPY . ./

RUN go build -o deployment-service cmd/deployment-service/main.go

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/

COPY --from=builder /workspace .

ARG DEFAULT_PORT=8080
ENV PORT $DEFAULT_PORT

EXPOSE $PORT

CMD ["./deployment-service"]

this is my run command,

docker run --name=${CONTAINER_NAME} -d --rm -p ${PORT}:80 -e DEPLOYMENT_SERVICE_DATABASE_CONNECTION_URI=mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_CONTAINER_NAME}:27017/ -e DEPLOYMENT_SERVICE_SERVER_SECRET_KEY=${SECRET_KEY} -e ANSIBLE_CONFIG='./jam-ansible/ansible.cfg' -e DEPLOYMENT_SERVICE_ANSIBLE_SUBMISSION_ROOT=${DEPLOYMENT_ROOT} -v ${DEPLOYMENT_VOLUME}:${DEPLOYMENT_ROOT} --network=${NETWORK_NAME} server:latest

help to get my issue solved.

答案1

得分: 3

似乎缺少执行 deployment-service 的权限。您可以在 CMD ["./deployment-service"] 之前添加以下代码:

RUN chmod +x deployment-service
英文:

It seems lack of permission to execute deployment-service. You can add

RUN chmod +x deployment-service

before CMD ["./deployment-service"]

答案2

得分: 2

看起来你需要编辑deployment-service文件的权限。

尝试在终端中运行以下命令:

chmod a+x ./deployment-service

然后再试一次。

英文:

looks like you need to edit the permissions of the deployment-service file.

try running

chmod a+x ./deployment-service

in the terminal then trying again.

答案3

得分: 0

在我的情况下,当我尝试使用以下命令运行容器时,出现了以下错误:

docker container run -p 端口号:端口号 amazoncorretto:17-alpine-jdk

错误信息:

docker: 守护程序的错误响应: 创建shim任务失败: OCI运行时创建失败: runc创建失败: 无法启动容器进程: exec: "bash": 在$PATH中找不到可执行文件: 未知。

我使用了amazoncorretto:17-alpine-jdk的Docker镜像,并且在dockerfile中,我将bash改为了sh,这样就可以在alpine中正常工作了。

命令从:

CMD ["bash", "-c", "java -jar test.jar"]

改为:

CMD ["sh", "-c", "java -jar test.jar"]
英文:

In my case, I got the below error while trying to run the container using the command:

docker container run -p portnumber:portnumber amazoncorretto:17-alpine-jdk

ERROR:
>docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown.

  • I used amazoncorretto:17-alpine-jdk docker image and in dockerfile instead of bash, I changed it to sh and it worked as bash didn't work with alpine.

Command changed from:

CMD ["bash", "-c", "java -jar test.jar"]

to:

CMD ["sh", "-c", "java -jar test.jar"]

答案4

得分: 0

有时候你可能会遇到这个错误,因为你没有为容器指定入口点。
你可以在 Dockerfile 中使用 ENTRYPOINT 来指定入口点。

以下是一个 .NET 的示例:

ENTRYPOINT ["dotnet", "application.dll"]
英文:

Sometimes you may end up getting this error because you have not specified an entrypoint for your container.
You can do that using ENTRYPOINT inside the Dockerfile

Below is a .NET example:

ENTRYPOINT ["dotnet", "application.dll"]

答案5

得分: -3

运行 docker system prune -a 命令
清除所有缓存和停止的容器
然后尝试启动 Docker。
它会启动。

英文:

Run docker system prune -a
clear all cache and stopped containers
and then try starting the docker.
It'll start.

huangapple
  • 本文由 发表于 2023年1月11日 13:40:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75078744.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定