52

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 ?

shgnInc
  • 2,054
  • 1
  • 23
  • 34
Kush Patel
  • 3,685
  • 5
  • 42
  • 65

4 Answers4

91

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.

TheCyberliem
  • 1,178
  • 12
  • 14
  • 2
    same issues, following this Google CLoud Platform tutorial [https://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 windows – Brigitte Maillère Nov 27 '19 at 14:46
  • 1
    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 `RUN` – mtpultz Jan 05 '21 at 21:50
  • 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://stackoverflow.com/a/69483712/9888057) – StephenWeiss Jan 21 '23 at 21:20
15

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.

Dinei
  • 4,494
  • 4
  • 36
  • 60
4

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"

Bold
  • 213
  • 1
  • 4
  • 11
-2

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

B.Mind
  • 17
  • 3