node.js - 标准_init_linux.go :190: exec user process caused "exec format error" The command '/bin/sh -c npm install' returned a non-zero code: 1

标签 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

最佳答案

RUN指令有两个写法forms

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

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

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

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

你可以按照上面的评论升级 npm 镜像。希望有帮助~

关于node.js - 标准_init_linux.go :190: exec user process caused "exec format error" The command '/bin/sh -c npm install' returned a non-zero code: 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52116459/

相关文章:

node.js - 如何使用 Firebase Cloud Function 加密字符串

mysql - 如何在不在主机上发布端口的情况下访问在 docker 容器(由 Rancher 管理)中运行的 MySQL?

git - Jenkins 的 npm install 无法安装托管在 bitbucket 上的模块

node.js - Cat 显示日志中没有任何内容( express 服务器)

javascript - sailsjs 创建两个模型时的错误处理

Docker for Windows 不工作

windows - Windows Server 2016 TP4上的Docker通过powershell下载容器中的git

node.js - 未捕获: SyntaxError: Cannot use import statement inside the Node. js REPL,或者使用动态导入

javascript - 为什么我在 Node 中使用 mysql 的 connection.query 不起作用?

.net - SQL Server 数据库插入/更新 TCP 通知