I have a multistage dockerfile
which I'm deploying in k8s with script as ENTRYPOINT ["./entrypoint.sh"]
.
Deployment is done though helm and env is Azure. While creating the container it errors out "./entrypoint.sh": permission denied: unknown
Warning Failed 14s (x3 over 31s) kubelet Error: failed to create containerd task: OCI runtime create failed: container_linux.go:380: starting container process caused:
exec: "./entrypoint.sh": permission denied: unknown
Warning BackOff 1s (x4 over 30s) kubelet Back-off restarting failed container
I have given chmod +x
to make it executable and chmod 755
for permission.
Dockerfile
##############
## Build #
##############
FROM repo.azurecr.io/maven:3.8.1-jdk-11 AS BUILD
ARG WORKDIR=/opt/work
COPY . $WORKDIR/
WORKDIR ${WORKDIR}
COPY ./settings.xml /root/.m2/settings.xml
RUN --mount=type=cache,target=/root/.m2/repository \
mvn clean package -pl app -am
RUN rm /root/.m2/settings.xml
RUN rm ./settings.xml
#################
### Runtime #
#################
FROM repo.azurecr.io/openjdk:11-jre-slim as RUNTIME
RUN mkdir /opt/app \
&& useradd -ms /bin/bash javauser \
&& chown -R javauser:javauser /opt/app \
&& apt-get update \
&& apt-get install curl -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=BUILD /opt/work/app/target/*.jar /opt/app/service.jar
COPY --from=BUILD /opt/work/entrypoint.sh /opt/app/entrypoint.sh
RUN chmod +x /opt/app/entrypoint.sh
RUN chmod 755 /opt/app/entrypoint.sh
WORKDIR /opt/app
USER javauser
ENTRYPOINT ["./entrypoint.sh"]
PS: Please don't make it duplicate of https://stackoverflow.com/a/46353378/2226710 as i have added RUN chmod +x entrypoint.sh
and it didn't solved the issue.
Use bash
(or your preferred shell if not bash
) in the entrypoint:
ENTRYPOINT [ "bash", "-c", "./entrypoint.sh" ]
This will run the entrypoint script even if you haven't set the script as executable (which I see you have)
You an also use this similarly with other scripts, for example with Python:
ENTRYPOINT [ "python", "./entrypoint.py" ]
You could also try calling the script with full executable path:
ENTRYPOINT [ "/opt/app/entrypoint.sh" ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With