Search code examples
dockerentry-pointdocker-entrypoint

getting permission denied in docker run


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 ?


Solution

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