standard_init_linux.go:190:exec用户进程导致“ exec格式错误”命令'/ bin / sh -c npm install'返回了非零代码:1

时间:2018-08-31 13:25:31

标签: node.js docker npm dockerfile

我是docker的新手,出于学习目的,我遵循了官方的nodejs docker指导,并遵循了说明,但是它始终在同一命令上引发错误。

我尝试在Raspberry Pi上将图像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

和docker版本

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

1 个答案:

答案 0 :(得分:0)

RUN指令有两次写入forms

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

不幸的是,它回复了non-zero error。众所周知, shell脚本会在发生错误时回复非零错误。

我对npm不熟悉。但是我仍然可以看到该错误与docker现在无关,而与shell脚本本身有关。

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

您可以按照上面的评论升级npm映像。可以帮忙〜