正在运行带有暂存Docker映像的NodeJs二进制文件

问题描述 投票:0回答:2

我们可以使用pkg package将NodeJs应用程序转换为二进制文件。我想构建二进制文件并使用Docker pkg镜像运行它。

scratch

index.js

const http = require('http') http.createServer().listen(3000)

Dockerfile

当我运行FROM node:10 as build COPY index.js . RUN npm i pkg -g && pkg -t node10-alpine-x64 index.js FROM scratch COPY --from=build index /index ENTRYPOINT ["/index"] 时,出现此错误消息-docker build -t index . && docker run --rm -it index

我想念什么?

node.js docker binary dockerfile alpine
2个回答
0
投票

standard_init_linux.go:211: exec user process caused "no such file or directory"是一个完全没有文件的空映像,您的二进制文件可能具有依赖性,并且期望某些Linux环境。尝试使用最少的linux基本映像而不是临时映像-scratchalpinedebian


0
投票

[我认为@Isanych是正确的,因为ubuntu可以很好地运行c ++,请执行二进制文件,但是我没有找到在scratch图像上运行pkg可执行文件的方法,因此这是基于的解决方案高山,但高山仍需要提到的某些依赖项scratch,并且正在使用下面的图像

您可以尝试这个

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