Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Node with dumb-init inside a Docker Container

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.
like image 712
Mike M Avatar asked Oct 22 '25 11:10

Mike M


1 Answers

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

like image 166
Shan-Desai Avatar answered Oct 25 '25 02:10

Shan-Desai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!