skip to Main Content

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.

4

Answers


  1. 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.

    Login or Signup to reply.
  2. 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"]
    
    Login or Signup to reply.
  3. 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"]
    
    Login or Signup to reply.
  4. It seems lack of permission to execute deployment-service. You can add

    RUN chmod +x deployment-service
    

    before CMD ["./deployment-service"]

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search