skip to Main Content

I am trying to use dumb-init in my docker container but the container OS cannot find the executable. My file is

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"]

and when I run it

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.

2

Answers


  1. You final nodejs:16 image is a debian based image, you however need to install dumb-init on it.

    RUN apt-get install dumb-init
    

    on debian / ubuntu based images

    RUN apk add dumb-init
    

    on Alpine based images

    Login or Signup to reply.
  2. I think a better approach here is to just use the docker image for dumb-init.

    For example..

    FROM building5/dumb-init:1.2.1 as init
    
    FROM node:16.15.0 as build
    COPY package*.json ./
    RUN npm install
    COPY . .
    
    FROM node:16.15.0 as prod
    COPY --from=init /dumb-init /usr/local/bin/
    COPY --from=build /usr/src/app/package*.json ./
    COPY --from=build /usr/src/app/node_modules ./node_modules
    
    EXPOSE 8080
    ENTRYPOINT ["/usr/local/bin/dumb-init", "--"]
    CMD ["node", "./server.js"]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search