I have a query, I build docker image locally ran it working fine. I pushed it to . . .

Ashutosh Pathak:
I have a query, I build docker image locally ran it working fine. I pushed it to ECR repo. Then I try running using kubernetes it is giving CrashLoopBackOff with Terminated and exit code 1

Tharanath:
did you check kubectl describe command

Ashutosh Pathak:
Yes it is giving State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1

Zack:
What do you mean by it’s running fine on local?

Ashutosh Pathak:
I created docker image for tomcat and did docker run it is working fine. Then I pushed the image to ECR and then on EKS I wrote Deployment.yaml where it is giving above error. When I did kubectl describe pod

Ayush Jain:
Do you see the messages about pulling the docker image from ECR repository?

Ayush Jain:
Please paste full message.

Ashutosh Pathak:
Events:
Type Reason Age From Message


Normal Scheduled 6m24s default-scheduler Successfully assigned default/tomcat-deployment-745f657dd4-ng6tg to ip-10-0-1-154.ap-south-1.compute.internal
Normal Pulled 6m10s kubelet Successfully pulled image “public.ecr.aws/i6b6v3j1/tomcat-repo:latest” in 13.520106681s
Normal Pulled 6m6s kubelet Successfully pulled image “public.ecr.aws/i6b6v3j1/tomcat-repo:latest” in 2.283368647s
Normal Pulled 5m47s kubelet Successfully pulled image “public.ecr.aws/i6b6v3j1/tomcat-repo:latest” in 2.285123405s
Normal Created 5m16s (x4 over 6m9s) kubelet Created container tomcat
Normal Started 5m16s (x4 over 6m9s) kubelet Started container tomcat
Normal Pulled 5m16s kubelet Successfully pulled image “public.ecr.aws/i6b6v3j1/tomcat-repo:latest” in 2.297448812s
Normal Pulling 4m35s (x5 over 6m23s) kubelet Pulling image “public.ecr.aws/i6b6v3j1/tomcat-repo:latest”
Warning BackOff 82s (x24 over 6m5s) kubelet Back-off restarting failed container

Ashutosh Pathak:
In logs it is giving

Ashutosh Pathak:
standard_init_linux.go:228: exec user process caused: exec format error

unnivkn:
Hi @Ashutosh Pathak
Before working on k8s, could you please try this docker commands & share the output.

##cleanup stopped container permenantly:
docker ps -a
docker rm <container-name>
docker ps -a

###Remove an Image, which is already downloaded from Docker Hub:

Make sure no containers are using this image before remove it

docker images
docker rmi tomcat-repo:latest

##Only pull an Image & not to create a container:
docker pull tomcat-repo:latest
docker images

Ashutosh Pathak:
I removed container and image

Ashutosh Pathak:
then pulled the image it is giving output

Ashutosh Pathak:
latest: Pulling from i6b6v3j1/tomcat-repo
Digest: sha256:c2eb0139153bb16a646b816b9214c49ab4fbcacb53f3009916bccf628dfe91f7
Status: Downloaded newer image for public.ecr.aws/i6b6v3j1/tomcat-repo:latest

Ashutosh Pathak:
I am able to run this docker image after pull

Ashutosh Pathak:
but same is creating problem when I tried it from K8s Deployment yaml

Ashutosh Pathak:
it’s a public image can anyone try this

George Lazaroff:
Its because of diff OS architecture, maybe you built the image on diff OS architecture, that’s the reason, try to build the image for amd64, arm, etc… if you built the image on Raspberry pi then you wanna run it on amd64, it’s not possible

George Lazaroff:

standard_init_linux.go:228: exec user process caused: exec format error.       

The log above shows very well that the image is built on diff OS arch

Ashutosh Pathak:
ok should I use buildx of docker to have diff target envt.