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
looks like you need to edit the permissions of the deployment-service file.
try running
in the terminal then trying again.
In my case, I got the below error while trying to run the container using the command:
ERROR:
amazoncorretto:17-alpine-jdk
docker image and indockerfile
instead ofbash
, I changed it tosh
and it worked asbash
didn’t work withalpine
.Command changed from:
to:
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 theDockerfile
Below is a .NET example:
It seems lack of permission to execute deployment-service. You can add
before
CMD ["./deployment-service"]