我正在从一台 x86_64
机器上构建 docker 镜像,以便在部署服务器(arm64
)上使用。为了测试,我正在使用下面的 docker 文件。
FROM node:14.16.0-buster
RUN npm install pm2@latest -g
由于某些原因,npm install
失败了。我也尝试了 npm -v
但也失败了。请查看下面的控制台日志以获取更清楚的信息。
$~ docker buildx create --platform linux/arm64 --use --name arm64
arm64
$~ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
arm64 * docker-container
arm640 unix:///var/run/docker.sock inactive linux/arm64*
default docker
default default running linux/amd64, linux/386
$~ docker buildx build --platform linux/arm64 -t fos-node --load .
[+] Building 146.3s (7/7) FINISHED
=> [internal] booting buildkit 29.7s
=> => pulling image moby/buildkit:buildx-stable-1 28.6s
=> => creating container buildx_buildkit_arm640 1.1s
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 770B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 380B 0.0s
=> [internal] load metadata for docker.io/library/node:14.16.0-buster 13.6s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [1/2] FROM docker.io/library/node:14.16.0-buster@sha256:e09a63130ce4ec4b20af5bd07e2029a0ef26f64f1f496f0854f5b1ff1aa69575 102.0s
=> => resolve docker.io/library/node:14.16.0-buster@sha256:e09a63130ce4ec4b20af5bd07e2029a0ef26f64f1f496f0854f5b1ff1aa69575 0.0s
=> => sha256:4d7f255f49584b155894f79821624b3502337e5825df64c3be03a07f04fb1691 282B / 282B 0.4s
=> => sha256:ec755c817ff697a94525832b7ac0c6e41048d90ac0da7e9454a5fe5c1a04caf9 2.31MB / 2.31MB 2.2s
=> => sha256:238768c628173281bc3162a29cef7923808d66159e7249d80620b4221632200b 34.64MB / 34.64MB 33.4s
=> => sha256:754863281868391e5f6c82b8b29b874f9e1830f1919ac097ca6560a6ef747976 4.20kB / 4.20kB 1.7s
=> => sha256:ccc089388c7ca4407aec7247a44601b896e57e96d53a858fb0e8c6f2f94ab8da 183.90MB / 183.90MB 96.0s
=> => sha256:ba70c372ae296f23e908bf1e1ed9f4c0c81a8a6d7fc48c0e2db16035bb9b7a54 52.17MB / 52.17MB 58.0s
=> => sha256:299f3631f6b52be065a7342da0a46978d55cbd0d15c57fae22f4ca24efcc295a 9.98MB / 9.98MB 13.6s
=> => sha256:344d2d9a9cf41c137b0dbb41df255f95fb812a23771a10ee2ab5a8a5047c62c4 7.69MB / 7.69MB 18.6s
=> => sha256:ef28e7e77ecbd3b3b426832bc12e8f5e629959683767466e9bac149c3286e126 49.23MB / 49.23MB 59.1s
=> => extracting sha256:ef28e7e77ecbd3b3b426832bc12e8f5e629959683767466e9bac149c3286e126 1.5s
=> => extracting sha256:344d2d9a9cf41c137b0dbb41df255f95fb812a23771a10ee2ab5a8a5047c62c4 0.2s
=> => extracting sha256:299f3631f6b52be065a7342da0a46978d55cbd0d15c57fae22f4ca24efcc295a 0.2s
=> => extracting sha256:ba70c372ae296f23e908bf1e1ed9f4c0c81a8a6d7fc48c0e2db16035bb9b7a54 1.6s
=> => extracting sha256:ccc089388c7ca4407aec7247a44601b896e57e96d53a858fb0e8c6f2f94ab8da 4.5s
=> => extracting sha256:754863281868391e5f6c82b8b29b874f9e1830f1919ac097ca6560a6ef747976 0.0s
=> => extracting sha256:238768c628173281bc3162a29cef7923808d66159e7249d80620b4221632200b 1.4s
=> => extracting sha256:ec755c817ff697a94525832b7ac0c6e41048d90ac0da7e9454a5fe5c1a04caf9 0.1s
=> => extracting sha256:4d7f255f49584b155894f79821624b3502337e5825df64c3be03a07f04fb1691 0.0s
=> ERROR [2/2] RUN npm install pm2@latest -g 0.3s
------
> [2/2] RUN npm install pm2@latest -g:
------
Dockerfile:3
--------------------
1 | FROM node:14.16.0-buster
2 |
3 | >>> RUN npm install pm2@latest -g
4 |
5 | # RUN mkdir -p /home/ubuntu
--------------------
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/dev/.buildkit_qemu_emulator /bin/sh -c npm install pm2@latest -g]: exit code: 1
我认为在
npm install
之后发生了segmentation fault
,因为运行docker build
的主机shell是x86_64
,这只是一个假设。欢迎任何帮助。