运行 在 Docker 容器中带有 dumb-init 的节点
Running Node with dumb-init inside a Docker Container
我正在尝试在我的 docker 容器中使用 dumb-init,但容器 OS 找不到可执行文件。我的文件是
FROM node:16 AS builder
RUN apt update
RUN apt install dumb-init
WORKDIR /app
COPY package.json .
RUN yarn install
COPY . .
RUN yarn run build
FROM node:16 AS production
WORKDIR /app
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/yarn.lock ./yarn.lock
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["node", "dist/main"]
当我 运行 它
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/usr/bin/dumb-init": stat /usr/bin/dumb-init: no such file or directory: unknown.
您最终的 nodejs:16
映像是基于 debian 的映像,但是您需要在其上安装 dumb-init
。
RUN apt-get install dumb-init
基于 debian/ubuntu 的映像
RUN apk add dumb-init
在基于 Alpine 的图像上
我正在尝试在我的 docker 容器中使用 dumb-init,但容器 OS 找不到可执行文件。我的文件是
FROM node:16 AS builder
RUN apt update
RUN apt install dumb-init
WORKDIR /app
COPY package.json .
RUN yarn install
COPY . .
RUN yarn run build
FROM node:16 AS production
WORKDIR /app
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/yarn.lock ./yarn.lock
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["node", "dist/main"]
当我 运行 它
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/usr/bin/dumb-init": stat /usr/bin/dumb-init: no such file or directory: unknown.
您最终的 nodejs:16
映像是基于 debian 的映像,但是您需要在其上安装 dumb-init
。
RUN apt-get install dumb-init
基于 debian/ubuntu 的映像
RUN apk add dumb-init
在基于 Alpine 的图像上