상황
M1 맥북에서 빌드한 이미지를 GKE에서 이용하였을 때 오류가 발생하며 파드가 정상적으로 시작되지 않는 문제
원인
도커 이미지가 빌드된 플랫폼과 컨테이너가 실행될 플랫폼이 달라서 생기는 문제이다. uname -a 명령어를 이용해 플랫폼을 확인해보면 M1 맥북은 arm64, GKE에서 노드로 사용되는 VM은 amd64(x86_64) 임을 확인할 수 있다. 따라서 이미지를 빌드할 때 이미지가 사용될 플랫폼을 지정해주거나, 컨테이너를 실행할 때 이미지가 빌드된 플랫폼을 알려주는 방식으로 문제를 해결할 수 있다.
추가적으로 Docker 메뉴얼에 애플 실리콘과 관련된 문제에 관련된 내용이 존재한다.
Some images do not support the ARM64 architecture. You can add -platform linux/amd64 to run (or build) an Intel image using emulation.
In summary, running Intel-based containers on Arm-based machines should be regarded as “best effort” only. We recommend running arm64 containers on Apple silicon machines whenever possible, and encouraging container authors to produce arm64, or multi-arch, versions of their containers. We expect this issue to become less common over time, as more and more images are rebuilt supporting multiple architectures.
해결책
다음 명령어를 통해 이미지가 사용될 플랫폼을 지정하여 이미지를 빌드한다.
docker buildx build --platform linux/amd64 ...
잘못된 내용, 오타, 부정확한 문장 등 어떤 피드백이든 환영합니다. 감사합니다.