【发布时间】:2020-06-16 01:53:05
【问题描述】:
我们可以使用pkg package 将 NodeJs 应用程序转换为二进制文件。我想构建二进制文件并使用 Docker 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 时,我收到此错误消息 - standard_init_linux.go:211: exec user process caused "no such file or directory"。
我错过了什么?
【问题讨论】:
标签: node.js docker binary dockerfile alpine