I have created an image of my app using docker and when I run the docker image on my local machine it runs successfully, but the same image is erroring out when running using kubernetes.
The error is: exec /docker-entrypoint.sh: exec format error
Upon surfing the net for possible solutions I found the suggestion to add the shebang at the start of the docker-entrypoint.sh
. But this is a default .sh file as I've not specified any ENTRYPOINT in my dockerfile. I am not able to understand where to add the shebang.
Here is my dockerfile:
# pull the official base image
FROM node:18-alpine as builder
ENV NODE_ENV production
# set working direction
WORKDIR /app
# install application dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm i --production
# add app
COPY . .
# Build the app
RUN npm run build
# Bundle static assets with nginx
FROM nginx:1.23.1-alpine as production
ENV NODE_ENV production
# Copy built assets from builder
COPY --from=builder /app/build /usr/share/nginx/html
# Add your nginx.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]
Some information about the image created:
"Architecture": "arm64",
"Variant": "v8",
"Os": "linux",
"Cmd": ["nginx", "-g", "daemon off;"],
"Entrypoint": ["/docker-entrypoint.sh"]