Search code examples
dockerdocker-composebundlerqemuapple-m1

Qemu error when running gem install bundler on Docker with Apple Silicon M1


When I run docker-compose up I'm getting the following error

qemu: uncaught target signal 6 (Aborted) - core dumped

This is happening when docker-compose is running the command bundle install

 => ERROR [5/6] RUN bundle install --jobs 4 --path .bundle/                                                                                                                  4.2s
------
 > [5/6] RUN bundle install --jobs 4 --path .bundle/:
#10 4.170 Fetching gem metadata from https://rubygems.org/.[BUG] Segmentation fault at 0x0000418f81e2b0
#10 4.177 ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]
#10 4.177
#10 4.177 SEGV received in SEGV handler
#10 4.178 -- Control frame information -----------------------------------------------
#10 4.178 SEGV received in SEGV handler
#10 4.178 SEGV received in SEGV handler
#10 4.178 qemu: uncaught target signal 6 (Aborted) - core dumped
#10 4.192 Aborted
------
executor failed running [/bin/sh -c bundle install --jobs 4 --path .bundle/]: exit code: 134

According to this github issue thread on docker's github – its a qemu related bug:

https://github.com/docker/for-mac/issues/5148#issuecomment-784992663

It mentions that qemu is the upstream component Docker use for running Intel (amd64) containers on M1 (arm64) chips. I checked the qemu repo fora related issues with no luck:

https://gitlab.com/qemu-project/qemu/-/issues?scope=all&utf8=%E2%9C%93&state=opened&search=uncaught+target+signal+6

In my docker-compose file I've passed the following config which helped me fix a couple M1 related issue on docker. But this isn't working for this specific issue.

web:
    platform: linux/amd64
    ...

This issue is happening on the following environment

  • Macbook Pro M1 2020
  • Mac OS Big Sur 11.2.3
  • docker-compose version 1.29.1
  • docker engine: 20.10.6
  • docker desktop 3.3.3(64133)

I've also opened an issue on qemu repo as well: https://gitlab.com/qemu-project/qemu/-/issues/340

Any ideas on how to fix this?


Solution

  • I found a hack. This is a way around that specific issue. I fixed it by adding the following line at the top of my Dockerfile.yml to update the image source which might have been outdated

    FROM ruby:2.3.4
    

    If you're experiencing a similar issue with another library I suggest looking for an image on Docker Hub https://hub.docker.com/ and making sure that they have support for the desired architecture: amd64 or arm64, etc...


    For more information about the qemu error, you can follow this GitLab issue thread: https://gitlab.com/qemu-project/qemu/-/issues/340