Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker buildx with node app on Apple M1 Silicon - standard_init_linux.go:211: exec user process caused "exec format error

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?

like image 741
helloMoto Avatar asked Feb 06 '21 18:02

helloMoto


People also ask

Does buildx require Docker_buildkit?

Buildx builds using the BuildKit engine and does not require DOCKER_BUILDKIT=1 environment variable to start the builds. The docker buildx build command supports features available for docker build, including features such as outputs configuration, inline build caching, and specifying target platform.

What is exec format error in Docker?

Docker throws error standard_init_linux.go:228: exec user process caused: exec format error when there are issues with executable file format. It could happen due to these reasons – You forgot to put #!/bin/bash at the top of shell files. There is a space before shebang ( #!/bin/bash ). Using #!/bin/bash instead of #!/bin/ash for alpine images.

How do I enable Docker buildx on a MacBook Air?

It was written with an Apple M1 equipped MacBook Air so results may vary across devices. The Docker buildx feature is currently “experimental” so we need to enable Docker Desktop’s experimental feature support. To do so, open up Docker Desktop then navigate to Preferences.

Is the Mac M1 compatible with Docker?

After more than a decade of using Macs, I recently purchased a Mac (mini) M1 to replace my dying laptop. I had been hesitant to get one due to potential software incompatibility, but thankfully things turned out to be fine. Mostly. I had no issues with Docker, until the build was pulled onto a live ubuntu server (see error in image above). Oops.


1 Answers

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

FROM --platform=linux/amd64 node:10-alpine
like image 167
mateuskb Avatar answered Oct 26 '22 23:10

mateuskb