Home > Backend Development > Golang > QEMU-x86_64 on ARM64 Docker: How to Fix 'No such file or directory' Errors?

QEMU-x86_64 on ARM64 Docker: How to Fix 'No such file or directory' Errors?

Mary-Kate Olsen
Release: 2024-12-19 09:48:10
Original
309 people have browsed it

QEMU-x86_64 on ARM64 Docker: How to Fix

No Such File or Directory Error: Troubleshooting QEMU-x86_64 on ARM64 Docker Builds

When building Docker images on M1 MacOS using QEMU-x86_64, users may encounter the error "qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory." This error occurs because the ARM64 M1 architecture does not have the x86_64 shared object library required by the Dockerfile.

To resolve this issue, the solution lies in changing the platform specified in the Dockerfile's FROM directive. Instead of using the default ARM64 platform, explicitly specify the linux/amd64 platform as follows:

FROM --platform=linux/amd64 ubuntu:20.04
Copy after login

This change forces Docker to use an x86_64 base image, which includes the necessary shared object libraries. As a result, the build process will attempt to install and execute code explicitly compiled for x86_64.

Alternatively, if possible, consider using an ARM64 base image and compiling software for x86_64 within the container during build time. While possibly slower due to emulation, this approach can yield increased performance when running the container on M1-based Macs.

The above is the detailed content of QEMU-x86_64 on ARM64 Docker: How to Fix 'No such file or directory' Errors?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template