Executable not running in POD, but runs in Docker container

Cluster information:

Kubernetes version: 1.27.2
Cloud being used: docker-desktop’s kubernetes and AKS (Azure)
Installation method:
Host OS: Mac Os Sonoma 14

Hello, I built a docker image containing an executable linux file (named app). When I launch the container with docker run the executable spins up and everything works fine.

If I pull that same image to my kubernetes cluster (both docker-desktop’s and azure’s) nothing happens and the created POD starts a crashbackoff loop. I put a wait command in the deployment yaml and entered the pod with sh, running sh -x ./app returns
/app: 1: Syntax error: ")" unexpected

How can the same executable run in a container, but not in a POD?

This is driving me crazy, any idea? Thanks

Post your Pod/Deployment/Job YAML.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: registration-native
spec:
  replicas: 1
  selector:
    matchLabels:
      component: registration-native
  template:
    metadata:
      labels:
        component: registration-native
    spec:
      containers:
        - name: registration-native
          image: local/repo:registration-native
          imagePullPolicy: "Never"
          ports:
            - containerPort: 8080

It’s the simplest possible. The image is taken directly from my local environment, but i also tried to pull it from my repo at docker hub.

Are you setting ther pod.spec.container command or args ?

running sh -x ./app returns
/app: 1: Syntax error: ")" unexpected

Is the app a shell script?

It looks like the shell in your container doesn’t parse it.

It is a native java native image, a linux executable. What is not clear to me is how it works in docker but not in the pod. Does kubernetes interpreter is somehow different?

It could be that the VM doesn’t have the right binfmt modules loaded to run Java directly. Usually one would run it as java <file>, right? It’s been a while since I Java’ed.

sh -x means “run this as a shell script” which is not what you want.

I found the library that was causing the issue, spring cloud kubernetes. Still it’s not clear to me why it works in a container but not in a pod. Anyway, issue solved!