N
N
nurzhannogerbek2019-03-12 10:27:18
go
nurzhannogerbek, 2019-03-12 10:27:18

How to fix docker: Error response from daemon: oci runtime error: container_linux.go issue?

Hello! Help fix the problem.
There is the following Dockerfile :

FROM golang:1.11

RUN mkdir /app

WORKDIR /app

ADD . $SRC_DIR

EXPOSE 8000

ENTRYPOINT ["./service"]

With this Dockerfile, I successfully create an image (image), but when I try to create a container, I get an error:
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"./service\": permission denied".

To create a docker container, use the command:
sudo docker run --name service_container -d -p 8000:8000 service_image

By the way, the service file is a compiled binary file of the Golang application. Before creating the container or image, I made this binary executable with the command:
sudo chmod 775 service
What did I forget to consider?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav, 2019-03-12
@nurzhannogerbek

Perhaps the rights were not transferred when adding the file to the container, try adding after adding the files:
But I do not quite understand why the golang:1.11 image is needed in this case, if ./service is already a compiled binary file.
If so, you can lighten the image by using scratch or alpine as the base image:

FROM alpine

ADD ./service /
RUN chmod +x /service

EXPOSE 8000
ENTRYPOINT ["./service"]

A
abmanimenja, 2019-03-12
@abmanimenja

The FROM GOLANG image is only needed for compilation, not for execution.
You carry the excess with you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question