Docker Community Forums

Share and learn in the Docker community.

Armv7 docker image created with QEMU action causes Illegal instruction

I build my docker images on Github, for three architectures at once. For the backend, I had to go through hoops and instead using node:latest, use ubuntu:latest so that I can use glibc >= 2.29. However, it looks like launching anything that is installed when building that file - so npm or nodejs - will cause the image to crash on armv7, while working on x86_64:

backend_1   | #
backend_1   | # Fatal error in , line 0
backend_1   | # unreachable code
backend_1   | #
backend_1   | #
backend_1   | #
backend_1   | #FailureMessage Object: 0xbecf23ecIllegal instruction (core dumped)

Here is the Dockerfile:

FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install nodejs npm -y
RUN apt install ca-certificates -y
RUN update-ca-certificates --fresh
RUN npm install -g npm@latest
WORKDIR /code
EXPOSE 4000
COPY package*.json ./
RUN npm i
COPY . .
VOLUME /code/media
CMD "npm" "start"

And the relevant action:

runs-on: ubuntu-latest
steps:
  - uses: actions/checkout@v2
  -
    name: Set up QEMU
    uses: docker/setup-qemu-action@v1
  -
    name: Set up Docker Buildx
    uses: docker/setup-buildx-action@v1
  -
    name: Login to DockerHub
    uses: docker/login-action@v1 
    with:
      username: ${{ secrets.DOCKERHUB_USERNAME }}
      password: ${{ secrets.DOCKERHUB_TOKEN }}
  -
    name: Build and push
    id: docker_build
    uses: docker/build-push-action@v2
    with:
      push: true
      tags: XXXXXXXXXX/backend:latest
      context: backend
      file: ./backend/Dockerfile
      platforms: linux/amd64,linux/arm64,linux/arm/v7
  -
    name: Image digest
    run: echo ${{ steps.docker_build.outputs.digest }}

I assume the problem is using apt while using QEMU actions (which are, AFAIK, behind the hood buildx commands)? If there is a fix for that, I’m happy to take it. If there is a way to get node/npm and glibc >= 2.29 at the same time, without using apt, then I’m happy about that solution too. Basically anything that helps my mess works for me!

Thank you very much for your help!