I’m new with k8s and I’ve deployed a simple nginx deployment using eks and ecr. The problem only present when I’m using ecr image, it’s not happens with nginx public image from docker hub.
Here is my deployment file.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
imagePullSecrets:
- name: *-ecr-registry
containers:
- name: nginx
# image: nginx:latest
image: *.dkr.ecr.*.amazonaws.com/nginx:dev
Here is output of a pod.
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 12s default-scheduler Successfully assigned *
Normal Pulled 10s (x2 over 12s) kubelet Container image * already present on machine
Normal Created 10s (x2 over 12s) kubelet Created container nginx
Normal Started 10s (x2 over 11s) kubelet Started container nginx
Warning BackOff 8s (x2 over 9s) kubelet Back-off restarting failed container
Here is result log of the pod
exec /docker-entrypoint.sh: exec format error
I also ran the ecr image with docker in my local machine without any error.
Can someone give me some hints, how can I overcome this issue, thanks in advance.
2
Answers
After hours of trying many ways, I realize that I'm using base-image
keymetrics/pm2:18-alpine
only supports amd64 kernel. Even I tried to rebuild my image in arm64, that doesn't not work in my work nodes with arm64 kernel type. So I see 2 ways to overcome this issue is:node:18.14-alpine
that supports both arm64 and amd64 kernel.it’s due to you have built the Docker image on an ARM M1 chip either on Mac and try to run it on AMD or the opposite due to that it’s throwing an error.
You can build the docker image again by passing ARG –platform
Or you can also set the Environment variable
export DOCKER_DEFAULT_PLATFORM=linux/amd64
You can pass ARG with FROM in Dockerfile or while running command
docker build --platform
Dockerfile
ARG with build command
ref doc: https://docs.docker.com/engine/reference/builder/#from
You can also run the image with docker like