getting permission denied in docker run
Asked Answered
H

4

61

I am trying using Docker using Dockerfile.

My Dockerfile as follows, where I am using debian linux system.

FROM debian:jessie

ENV DEBIAN_FRONTEND noninteractive

ARG AIRFLOW_VERSION=1.7.1.3
ENV AIRFLOW_HOME /usr/local/airflow

..
..

COPY script/entrypoint.sh /entrypoint.sh
COPY config/airflow.cfg ${AIRFLOW_HOME}/airflow.cfg
..
..    
USER airflow
WORKDIR ${AIRFLOW_HOME}
ENTRYPOINT ["/entrypoint.sh"]

So when I run docker build -t test ., it build without problem.

However, when I run docker run -p 8080:8080 test.

It throws following error:

container_linux.go:247: starting container process caused "exec: \"/entrypoint.sh\": permission denied"
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/entrypoint.sh\": permission denied".

What is I am doing wrong ?

Highball answered 21/6, 2017 at 23:20 Comment(4)
Do this in the app repo: chmod +x entrypoint.shDesegregate
Robert's right. The container_linux.go:247 error just refers to an error thrown from the container's ENTRYPOINT or CMD. In this case, a permissions issue.Chasechaser
You are right robert, Thanks..Highball
I had a similar error because I tried to docker run a DIRECTORY (copy/paste mistake) instead of an executable FILE.Julenejulep
N
108

You need to change the permission of the bash file by chmod +x entrypoint.sh before calling ENTRYPOINT. So change your code to the following:

USER airflow
WORKDIR ${AIRFLOW_HOME}
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

Rebuild the image and run the container, it should work.

Neumann answered 21/9, 2017 at 21:23 Comment(3)
same issues, following this Google CLoud Platform tutorial [cloud.google.com/cloud-build/docs/quickstart-docker? ] I edited my code following your advice but still get the same permission denied error. FROM alpine COPY quickstart.sh / RUN chmod +x quickstart.sh CMD ["/quickstart.sh"] docker run gcr.io/autotagging-api/quickstart-image OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"/quickstart.sh\": permission denied": unknown. I am running docker desktop for windowsVenation
Adding the RUN doesn't appear to fix anything. I had to apply it to the file locally to test that everything was working, but still blocked by why the permissions are not changed using RUNCrayton
Is there a reason why the RUN command wouldn't work? I'm still getting unable to start container process: exec: "/usr/app/entrypoint.sh": permission denied: unknown after adding a RUN chmod +x entrypoint.sh Basically, I had to use Dinei's answer below (https://mcmap.net/q/322195/-getting-permission-denied-in-docker-run)Almanac
A
17

Since COPY copies files including their metadata, you can also simply change the permissions of the file in the host machine (the one building the Docker image):

$ chmod +x entrypoint.sh

Then, when running docker build -t test . the copied file will have the execution permission and docker run -p 8080:8080 test should work.

Obs.: I'm not advocating this as best practice, but still, it works.

Authors answered 7/10, 2021 at 15:21 Comment(0)
S
9

In your terminal, run "chmod +x entrypoint.sh"

or if the entrypoint.sh file is in a folder, run "chmod +x folder_name/entrypoint.sh"

Settera answered 28/9, 2022 at 19:38 Comment(0)
V
-2

I changed the location of the entrypoint in the dockerfolder and rebuild & it worked!

Vespiary answered 9/9, 2020 at 11:36 Comment(2)
Can you elaborate?Wade
sure, I replaced the path in Dockerfile were it's /entrypoint to /user/local/entrypoint and rebuild the image.Vespiary

© 2022 - 2024 — McMap. All rights reserved.