Kubernetes/Docker error after building on Macbook M1 - standard_init_linux.go:211: exec user process caused “exec format error”

6/1/2021

I'm getting the subject error when deploying my application to Kubernetes on Google Cloud.

From digging through this post - https://stackoverflow.com/questions/58298774/standard-init-linux-go211-exec-user-process-caused-exec-format-error - it seems like the problem may be caused by the fact I'm building on a Macbook M1.

The proposed solution was to build on another machine.

Does anyone know of an alternative solution to this? I'd rather not have to change my machine just to get around this problem.

Here are the logs output with kubectl logs

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  45s                default-scheduler  Successfully assigned default/api-6dd8df46dd-gfpvh to gke-mysite-staging-general-pool-d0c2609f-ljd9
  Normal   Pulled     38s                kubelet            Successfully pulled image "gcr.io/mysite/mysite-api/staging" in 4.51688779s
  Normal   Pulled     36s                kubelet            Successfully pulled image "gcr.io/mysite/mysite-api/staging" in 187.266825ms
  Normal   Pulling    18s (x3 over 42s)  kubelet            Pulling image "gcr.io/mysite/mysite-api/staging"
  Normal   Created    18s (x3 over 37s)  kubelet            Created container api
  Normal   Started    18s (x3 over 36s)  kubelet            Started container api
  Normal   Pulled     18s                kubelet            Successfully pulled image "gcr.io/mysite/mysite-api/staging" in 194.129326ms
  Warning  BackOff    1s (x6 over 35s)   kubelet            Back-off restarting failed container

Dockerfile

FROM ruby:2.7.0

ARG environment

ENV RAILS_ENV $environment

RUN apt-get update -qq && \
  DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
  build-essential \
  make \
  gcc \
  g++ \
  libxml2-dev \
  libxslt-dev \
  pkg-config \
  libcurl3-dev \
  libpq-dev \
  nodejs \
  cron \
  libgmp3-dev && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN mkdir /home/app
WORKDIR /home/app
COPY ./Gemfile /home/app/Gemfile
COPY ./Gemfile.lock /home/app/Gemfile.lock
RUN bundle update --bundler
RUN bundle install
COPY ./ /home/app

EXPOSE 3000

# Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]

Deployment is done with Helm:- helm upgrade mysite-api . -f values.yaml

replicaCount: 1

app_version: "0.1"

deployments:
  mysite_api:
    image: gcr.io/mysite/mysite-api/staging
    pullPolicy: Always
    name: api
    label: api
    replicas: 1
    port: 3000
    nodepool: general-pool
    command: '["bundle", "exec", "puma", "-C", "config/puma.rb"]'

services:
  - name: api
    label: api
    port_container: 3000
    port_service: 3000
    type: NodePort
    selector: app
    selector_value: api

autoscaling:
  - name: api
    label: api
    deployment: api
    enabled: true
    minReplicas: 1
    maxReplicas: 3
    targetCPUUtilizationPercentage: 80
    targetMemoryUtilizationPercentage: 80
-- s89_
apple-m1
docker
kubernetes
ruby-on-rails

0 Answers