12

Please help!

I am trying to deploy a docker image to a kuebernetes clusters. No problem until I switched to new Macbook Pro with M1.

Once I build the image on the m1 machine and deploy I get the following error from the kuebernetes pod: standard_init_linux.go:211: exec user process caused "exec format error"

After doing some research, I followed this medium post on getting docker buildx added and set up.

Once I build a new image using the new buildx and run it locally using the docker desktop (the m1 compatible preview version), it runs without issue. However the kubernetes pod still shows the same error. standard_init_linux.go:211: exec user process caused "exec format error"

My build command
docker buildx use m1_builder && docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 -f Dockerfile -t ${myDockerRepo} --push . '
During the build I see each platform logging out that it is running the commands from my Dockerfile.

My push command
docker push ${myDockerRepo} One odd thing to note is the sha256 digest in the docker push command response does not change.

Here is my docker file:

# Use an official Node runtime as a parent image
FROM node:10-alpine

# Copy the current directory contents into the container at /app
COPY dist /app

# Set the working directory to /app
WORKDIR /app

# Make port 8000 available to the world outside this container
EXPOSE 8000

# Run npm run serve:dynamic when the container launches
CMD ["node", "server"]

I am no docker expert, clearly. Started with a full head of hair. Down to 3 strands. Please save those 3 strands.

I appreciate all help and advice!

Update

I have pulled the image built by the M1 macbook down to my other macbook and could run the image locally via docker desktop. I am not sure what this means. Could it be just a kuebernetes setting?

moonkotte
  • 3,661
  • 2
  • 10
  • 25
helloMoto
  • 123
  • 1
  • 7
  • Hi helloMoto, welcome to SO. [The fine manual](https://docs.docker.com/buildx/working-with-buildx/) says that the `--platform` flag merely sets `$BUILDPLATFORM` and `$TARGETPLATFORM` and doesn't appear to "magically" convert the executables in your image to M1 or amd64. IMHO you are running uphill trying to build a container for a different architecture than the one you are going to run in production -- why not just use `--platforms linux/amd64` and lower the number of variables? – mdaniel Feb 06 '21 at 19:22
  • @mdaniel That makes tons of sense to narrow the scope of the problem by specifying the single platform. I updated my build command per the suggestion. Unfortunately, the error still persists – helloMoto Feb 06 '21 at 23:09

1 Answers1

28

Try adding --platform=linux/amd64 to your dockerfile:

FROM --platform=linux/amd64 node:10-alpine
mateuskb
  • 328
  • 4
  • 10
  • 2
    This worked for me. See this answer for a bit more detail on what is happening, why this error occurs, and why the solution works: https://stackoverflow.com/a/65952339/199475 – carbocation Jun 14 '21 at 13:29