简体   繁体   中英

Container works in docker but not in Kubernetes cluster

I encountered today an interesting problem while porting a application from my WSL instance to a raspberry pi.

I rebuilt the docker image on the raspberry and verified that it is running on the correct architecture. Here is my Dockerfile:

FROM node:14.15.0-alpine3.12
EXPOSE 8080

ENV CHROME_BIN="/usr/bin/chromium-browser" \
    NODE_ENV="production"
RUN set -x \
    && apk update \
    && apk upgrade \
    && apk add --no-cache \
    dumb-init \
    udev \
    ttf-freefont \
    chromium \
    && npm install puppeteer-core@1.10.0 --silent \
      \
      # Cleanup
      && apk del --no-cache make gcc g++ binutils-gold gnupg libstdc++ \
      && rm -rf /usr/include \
      && rm -rf /var/cache/apk/* /root/.node-gyp /usr/share/man /tmp/* \
      && echo

WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install
COPY . .

ENTRYPOINT [ "sh","/usr/src/app/run.sh" ]

The ```run.sh´´´ file is very simple and just runs the node project.

#!/bin/bash
npm start

For the deployment I have a straight forward file containing the deployment pulling the image from the local registry.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ds-deployment
  namespace: absorbeo
  labels:
    kubernetes.labels.app: ds-server
spec:
  replicas: 1
  selector:
      matchLabels:
        app: ds-server        
  template:
    metadata:
      labels: 
        app: ds-server
    spec:
      containers:
      - image: localhost:32000/download-server
        imagePullPolicy: IfNotPresent
        name: ds-server
        ports:
        - containerPort: 8080
          name: ds-port        
        resources:
          limits:
            memory: 180Mi
            cpu: 250m
          requests:
            memory: 128Mi
            cpu: 100m

---
kind: Service
apiVersion: v1
metadata:
  name: ds-server-svc
  namespace: absorbeo
spec:
  selector:
    app: ds-server
  type: LoadBalancer
  ports:
  - port: 3000
    targetPort: 80

When inspecting the log output of the pod, I get the following error

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

I can't see any files using wrong encoding or the missing the shebang line. When running the same container on the installed Docker it works without any issues.

Am I doing anything wrong, is is my first time running a Micro8ks server on a raspberry pi.

Thanks in advance!

Add this code

#!/bin/bash

at the top of your script file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM