英文:
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
问题
我有一个在M1 MacOS上的Rancher Deskop(dockerd),当我尝试构建下面的dockerfile时,出现了以下错误。这是我尝试构建镜像的命令:docker build -t te-grafana-dashboards-toolchain --no-cache .
我尝试更改平台,但没有一个适用于我。我对M1上的平台问题有点困惑,但是任何帮助都将不胜感激。我做错了什么?这可能是什么原因?
移除中间容器70af516d5d6b
---> a69229847153
步骤 5/6 : RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb
---> 正在运行 13545862fffe
qemu-x86_64: 无法打开 '/lib64/ld-linux-x86-64.so.2': 没有那个文件或目录
qemu-x86_64: 无法打开 '/lib64/ld-linux-x86-64.so.2': 没有那个文件或目录
移除中间容器13545862fffe
Dockerfile
FROM --platform=linux/amd64 ubuntu:focal
RUN apt update; apt install -y curl jq build-essential python3.8 python3-pip docker-compose jsonnet bison mercurial
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN curl -OL https://golang.org/dl/go1.17.linux-amd64.tar.gz; mkdir /etc/golang; tar -xvzf go1.17.linux-amd64.tar.gz -C /etc/golang; ln -s /etc/golang/go/bin/go /usr/bin/go; rm -f go1.17.linux-amd64.tar.gz
RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb
WORKDIR /workspace
英文:
I have a Rancher Deskop(dockerd) on M1 MacOS and when I am trying to build below dockerfile I am getting an error such as below. Here is the command how I am trying to build the image docker build -t te-grafana-dashboards-toolchain --no-cache .
I tried to change the platforms but nonae of them worked for me. I am a bit lost about this platform issue for M1 but any help will be appreciated, What I am doing wrong? What might the root cause of this?
Removing intermediate container 70af516d5d6b
---> a69229847153
Step 5/6 : RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb
---> Running in 13545862fffe
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Removing intermediate container 13545862fffe
Dockerfile
FROM --platform=linux/amd64 ubuntu:focal
RUN apt update; apt install -y curl jq build-essential python3.8 python3-pip docker-compose jsonnet bison mercurial
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN curl -OL https://golang.org/dl/go1.17.linux-amd64.tar.gz; mkdir /etc/golang; tar -xvzf go1.17.linux-amd64.tar.gz -C /etc/golang; ln -s /etc/golang/go/bin/go /usr/bin/go; rm -f go1.17.linux-amd64.tar.gz
RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb
WORKDIR /workspace
答案1
得分: 167
顺便提一下,如果对其他人有帮助的话,我在一台M1 Max MacBook Pro笔记本上遇到了同样的问题,尝试从公司的代码库进行docker build
,这应该是一个非常常见的路径,但可能只有我一个人遇到了这个问题(因为我们是一家小公司),因为我使用的是ARM64 M1“Apple Silicon” Mac。然而,我找到了解决方案(至少是一个解决方案),与原帖中的解决方案完全相反,即在docker文件的FROM行中添加--platform=linux/amd64
。
示例:
FROM --platform=linux/amd64 ubuntu:20.04
否则,它会使用一个ARM64镜像作为起点,而我却不知情,然后在Dockerfile中尝试安装和执行为x86_64编译的代码。通过请求基础镜像为linux/amd64
来启动构建过程,最终基础镜像将具有/lib64/ld-linux-x86-64.so.2
。这可能意味着在ARM64 CPU上通过qemu-x86_64
模拟了所有的x86_64操作,因此如果你有选择从ARM64镜像开始,并且可以在构建过程中在容器内编译任何无法安装为ARM64二进制文件的软件,那么当你在基于M1的Mac上运行容器时,它可能会更快。对于这种情况,我目前还无法自行尝试。
英文:
Incidentally, in case it's helpful to another who lands here, I have the same issue on an M1 Max MacBook Pro laptop attempting to do a docker build
from a company repo that should be a pretty well traveled path, but I might be the only one (it's a small company) that has an ARM64 M1 "Apple Silicon" Mac. However I found the solution (well, a solution) to my situation was exactly the opposite of the solution to the OP's, and that was to add --platform=linux/amd64
to the FROM line of the docker file.
Example:
FROM --platform=linux/amd64 ubuntu:20.04
Otherwise it was using an ARM64 image to start from without me being the wiser but then later in the Dockerfile the build attempts to install and execute code compiled for x86_64. Starting the build process by requesting the base image be linux/amd64
ends up with then the base image having /lib64/ld-linux-x86-64.so.2
. This probably means everything is being emulated as x86_64 on the ARM64 CPU via qemu-x86_64
and so if you have the option to start from an ARM64 image and can compile within the container during build time any software you can't install as ARM64 binaries, it'll probably go faster when you later run the container on the M1 based Mac. I'm not able to try that myself just yet for this case.
答案2
得分: 20
修改Dockerfile
似乎是最常见的解决方法,但你也可以将DOCKER_DEFAULT_PLATFORM
环境变量设置为linux/amd64
。
export DOCKER_DEFAULT_PLATFORM=linux/amd64
问题似乎出现在AArch64镜像中。
英文:
Modifying Dockerfile
seems to be the most popular answer but you can also set the DOCKER_DEFAULT_PLATFORM
environment variable to linux/amd64
.
export DOCKER_DEFAULT_PLATFORM=linux/amd64
The cause seems to reside in the AArch64 image.
答案3
得分: 6
不需要编辑Dockerfile,如此答案中建议的,也不需要设置环境变量,如此答案中建议的。我更喜欢将平台作为参数传递给docker build
命令,并使用--platform
标志。OP使用的命令将是:
docker build --platform linux/amd64 -t te-grafana-dashboards-toolchain --no-cache .
英文:
Instead of editing the Dockerfile, as suggested in this answer, or setting an environment variable, as suggested in this answer, I prefer to pass the platform as an argument to the docker build
command, with the --platform
flag. The command used by the OP would then be:
docker build --platform linux/amd64 -t te-grafana-dashboards-toolchain --no-cache .
答案4
得分: 2
这解决了我的问题。
FROM ubuntu:focal
RUN apt update; apt install -y curl jq build-essential python3.8 python3-pip docker-compose jsonnet bison mercurial
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN curl -OL https://golang.org/dl/go1.17.linux-arm64.tar.gz; mkdir /etc/golang; tar -xvzf go1.17.linux-arm64.tar.gz -C /etc/golang; ln -s /etc/golang/go/bin/go /usr/bin/go; rm -f go1.17.linux-arm64.tar.gz
RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest; ln -s /root/go/bin/jb /usr/bin/jb
WORKDIR /workspace
英文:
this resolved my issue.
FROM ubuntu:focal
RUN apt update; apt install -y curl jq build-essential python3.8 python3-pip docker-compose jsonnet bison mercurial
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN curl -OL https://golang.org/dl/go1.17.linux-arm64.tar.gz; mkdir /etc/golang; tar -xvzf go1.17.linux-arm64.tar.gz -C /etc/golang; ln -s /etc/golang/go/bin/go /usr/bin/go; rm -f go1.17.linux-arm64.tar.gz
RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest; ln -s /root/go/bin/jb /usr/bin/jb
WORKDIR /workspace
答案5
得分: 2
将以下标志作为CPPFLAGS
传递给C预处理器可以解决我在M1上遇到的类似问题:
-DPNG_ARM_NEON_OPT=0
将该值作为环境变量的键CPPFLAGS
传递给相关服务。
英文:
Passing following flag to C preprocessor as CPPFLAGS
solved similar issue in my M1
-DPNG_ARM_NEON_OPT=0
Pass the value as env var with key CPPFLAGS
to relevant service.
答案6
得分: 2
提供的基础镜像包含目标架构的情况下,你可以尝试使用Docker内置的TARGETARCH
构建参数。这在我的 macOS M1 上有效。
FROM ubuntu:focal
ARG TARGETARCH
RUN apt update; apt install -y curl jq build-essential python3.8 python3-pip docker-compose jsonnet bison mercurial
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN curl -OL https://golang.org/dl/go1.17.linux-${TARGETARCH}.tar.gz; mkdir /etc/golang; tar -xvzf go1.17.linux-${TARGETARCH}.tar.gz -C /etc/golang; ln -s /etc/golang/go/bin/go /usr/bin/go; rm -f go1.17.linux-${TARGETARCH}.tar.gz
RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb
WORKDIR /workspace
英文:
Provided the base image includes the target architecture, another option that might work in your case is using Docker's built-in TARGETARCH
build arg. This works for me on macOS M1.
FROM ubuntu:focal
ARG TARGETARCH
RUN apt update; apt install -y curl jq build-essential python3.8 python3-pip docker-compose jsonnet bison mercurial
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN curl -OL https://golang.org/dl/go1.17.linux-${TARGETARCH}.tar.gz; mkdir /etc/golang; tar -xvzf go1.17.linux-${TARGETARCH}.tar.gz -C /etc/golang; ln -s /etc/golang/go/bin/go /usr/bin/go; rm -f go1.17.linux-${TARGETARCH}.tar.gz
RUN GO111MODULE="on" go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb; ln -s $(go env GOPATH)/bin/jb /usr/bin/jb
WORKDIR /workspace
答案7
得分: 1
我有一台Mac M1 Max电脑,在运行在KIND节点上的Kubernetes集群上使用Helm安装Camunda Platform 8时遇到了一个错误。错误发生在Camunda Operate的pod中。然而,在使用'--platform linux/amd64'选项更改默认镜像后,我成功启动了容器。
具体来说,我运行了以下命令:
docker pull camunda/operate:8.1.6 --platform linux/amd64
kind load docker-image --name camunda-platform-local camunda/operate:8.1.6
英文:
I have a Mac M1 Max computer and encountered an error when attempting to install Camunda Platform 8 using Helm on a Kubernetes cluster running on a KIND node. The error occurred in the Camunda Operate pod. However, after changing the default image using the '--platform linux/amd64' option, I was able to start the container successfully.
Specifically, I ran the following commands:
docker pull camunda/operate:8.1.6 --platform linux/amd64
kind load docker-image --name camunda-platform-local camunda/operate:8.1.6
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论