Home >Backend Development >Golang >How to Fix 'Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory' Error in QEMU on M1 Macs?
When attempting to build a Docker image on an M1 MacOS using Rancher Desktop, users may encounter the following error:
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
This issue arises due to the ARM64 architecture of the M1 processor, which is incompatible with the x86_64 architecture of the Docker image.
Resolution:
To resolve this issue, specify the desired Docker image architecture explicitly in the Dockerfile. Instead of using general-purpose platforms like "linux/amd64," specify either "linux/arm64" or "linux/arm64/v8." This ensures that the Docker image is built for the correct architecture and prevents the "Could not open" error.
Example:
FROM --platform=linux/arm64 ubuntu:focal
Alternatively, in certain cases, it might be necessary to modify the platform configuration in the docker build command itself. For instance, adding --platform=linux/amd64 to the command may work for some users on M1 Macs.
Customizing the Platform Configuration:
docker build --platform=linux/arm64 -t te-grafana-dashboards-toolchain --no-cache .
By explicitly specifying the desired architecture, users can ensure that the Docker image is built with the proper compatibility for their M1 MacOS system and avoid the aforementioned error.
The above is the detailed content of How to Fix 'Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory' Error in QEMU on M1 Macs?. For more information, please follow other related articles on the PHP Chinese website!