본문 바로가기
🌴 DevOps/Docker & K8s

[docker] Mac M1 이미지 빌드 오류 : qemu: uncaught target signal 6 (Aborted) - core dumped

by 카프리썬 2022. 3. 28.
728x90

상황

이미지 빌드

docker build -t $IMAGE_NAME:$IMAGE_TAG --progress=plain --platform linux/amd64 ..

이미지 실행 후 

 

에러메세지

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

 

경고

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

 

원인

M1(arm64) 칩에서 Intel(amd64) 컨테이너를 실행

빌드할 때 --platform 옵션으로  빌드 출력의 대상 플랫폼(예: linux/amd64, linux/arm64또는 darwin/amd64)을 지정한다. 

그런데 m1 노트북으로 도커파일을 빌드하여 도커이미지를 생성하면 platform이 linux/arm64으로 생성된다. 

그럼에도불구하고 방금 명령어를  linux/amd64로 지정하여 도커를 빌드했기때문에 문젝 발생한것. 

 

참고로 MAC m1 OS(Loca)이 아니라 아마존 리눅스를 사용하는 aws ec2에서는 linux/amd64로 docker 이미지가 생성된다. 

결국 맥북 m1에서 도커 컨테이너를 띄우려는 환경(linux/arm64)이랑 지정된 출력대상의 플랫폼(linux/amd64)이 달라서 생긴문제.

 

실제로 docker 측에서도 버그 리포트라고 인정(?)했다. 

https://github.com/docker/for-mac/issues/5342

 

tensorflow/latest image crashes with qemu core dump as soon as Tensorflow is loaded on M1 · Issue #5342 · docker/for-mac

[x ] I have tried with the latest version of Docker Desktop I have tried disabling enabled experimental features I have uploaded Diagnostics Diagnostics ID: I cannot find a button for it in your UI...

github.com

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

 

qemu: uncaught target signal 6 (Aborted) when running elixir amd64 image on M1 · Issue #5148 · docker/for-mac

I have tried with the latest version of my channel (Stable or Edge) I have uploaded Diagnostics Diagnostics ID: Expected behavior Image runs using qemu. Actual behavior > docker run --rm -it hex...

github.com

 

https://stackoverflow.com/questions/69189991/docker-running-linux-amd64-image-in-apple-m1-and-getting-qemu-uncaught-target

 

해결

m1 노트북으로 도커파일을 빌드하여 도커이미지를 생성하려면 맥 아키텍쳐에 맞춰서 이미지를 빌드한다. 

docker build -t $IMAGE_NAME:$IMAGE_TAG --progress=plain --platform linux/arm64  .

 

 

음 뒤에 platform 옵션을 지우고 그냥 이미지를 빌드 해도 되네?ㅎ

docker build -t $IMAGE_NAME:$IMAGE_TAG --progress=plain .

 

참고로 해당 이미지가 어떤 아키텍쳐 기반으로 만들어졌는지 아래와 같은 명령어로 볼수 있다.

sudo docker image inspect [이미지ID] | grep Architecture

반응형

$(document).ready(function() { var $toc = $("#toc"); $toc.toc({content: ".tt_article_useless_p_margin", headings: "h2,h3,h4"}); });