0

I have a Maven project with the following structure:

.
|-- Dockerfile
|-- entrypoint.sh
|-- pom.xml
|-- src
`-- target

My Dockerfile is:

FROM myimage


RUN groupadd --system --gid 7447 my-service
RUN adduser --system --gid 7447 --uid 7447 --shell /bin/bash --home /home/my-service my-service

WORKDIR /home/my-service

RUN chown -R my-service:my-service .
USER my-service


COPY --chown=my-service:my-service entrypoint.sh entrypoint.sh
COPY --chown=my-service:my-service target/my-service-0.0.1-SNAPSHOT.jar my-service.jar

EXPOSE 8080 15372

ENTRYPOINT ["/home/my-service/entrypoint.sh"]

while my entrypoint.sh is:

#!/usr/bin/env bash

exec java -XX:MaxRAMPercentage=75.0 -XX:InitialRAMPercentage=75.0 -jar /home/my-service/my-service.jar

When I build and run the docker image:

docker build . -t test --no-cache && docker run --rm

on my macOS laptop everything works. When I deploy the image to AWS EKS K8s hosted on Linux I suppose I get this error:

Error: failed to start container "my-service": Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/home/my-service/entrypoint.sh": stat /home/my-service/entrypoint.sh: no such file or directory

I experimented with chown but can't understand what the issue is.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
hitchhiker
  • 1,099
  • 5
  • 19
  • 44
  • 1
    Seems like you're taking care of everything in the Dockerfile (creating and setting workdir, copying entrypoint). My first guess would be you don't have the same version of the image on the k8s cluster. – erik258 Apr 17 '23 at 16:05
  • When I pull the built image and run it locally everything works so it's the same version. – hitchhiker Apr 18 '23 at 12:51

1 Answers1

0

The issue was that the image was deployed on Kubernetes using deployment which was creating a volume on /home/my-service directory while locally I was just running docker build . -t test --no-cache && docker run --rm without creating any volumes. Specifically, files in Docker volume override container files:

If the host volume/mount exists and contains files it will "override" whatever is in the container.

hitchhiker
  • 1,099
  • 5
  • 19
  • 44