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

问题描述 投票:1回答:1

我是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

和码头版

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
node.js docker npm dockerfile
1个回答
0
投票

RUN指令有两个写forms

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

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

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

也许这是其他评论中提到的语法或npm版本问题。它现在不是关于docker平台的。

您可以像上面的评论一样升级npm图像。愿这个帮助〜

© www.soinside.com 2019 - 2024. All rights reserved.