standard_init_linux.go:190:exec 用户进程导致"exec format error"命令'/bin/sh -c npm install'返回非零代码:1



我是docker的新手,出于我的学习目的,我遵循了官方nodejs docker指令并按照说明进行操作,但它在同一命令上不断抛出错误。

我尝试在树莓派上制作图像码头工人以用作服务器。 但是我在构建它以运行它时遇到问题

这是Dockerfile我

FROM node:4.3.2
WORKDIR /app
RUN npm install
EXPOSE (80)
CMD ["node", "index.js"]

错误

docker build -t hello-world .
Sending build context to Docker daemon  2.212MB
Step 1/5 : FROM node:4.3.2
---> 3538b8c69182
Step 2/5 : WORKDIR /app
---> Using cache
---> 7b8a5c56f23d
Step 3/5 : RUN npm install
---> Running in bbd6026d01d9
standard_init_linux.go:190: exec user process caused "exec format error"
The command '/bin/sh -c npm install' returned a non-zero code: 1

和码头工人版本

Containers: 19
Running: 0
Paused: 0
Stopped: 19
Images: 10
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs

Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.14.62-v7+
Operating System: Raspbian GNU/Linux 9 (stretch)
OSType: linux
Architecture: armv7l
CPUs: 4
Total Memory: 976.7MiB
Name: raspi2
ID: MJNK:BGTA:EFDS:B7VD:QZIL:T65S:IJRJ:ZO74:RG6D:BITS:AZNB:LDSC
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

RUN指令有两种写作形式。

在您的情况下,您已选择shell形式,RUN语句将被解析为/bin/sh -c run-statement(npm install here)

不幸的是,它回复了non-zero error.我们都应该知道,当错误发生时,shell脚本会回复非零错误。

我不熟悉npm.但我仍然可能会看到错误现在与 docker 无关,而是 shell 脚本本身。

也许是其他评论提到的语法或 npm 版本问题。现在与Docker平台无关。

您可以按照上面评论所述升级 npm 映像。愿这有帮助~

最新更新