Good Code
The good version uses exec form, so the application process receives termination signals directly.
Lesson 08
Use exec-form commands and keep startup wrappers signal-safe so containers stop gracefully.
FROM node:22-alpine
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY server.js ./server.js
# Exec form lets node receive Docker stop signals directly.
ENTRYPOINT ["node"]
CMD ["server.js"]FROM node:22-alpine
WORKDIR /app
COPY . .
RUN npm install
# Shell form wraps the app in a shell, making stop signals harder to handle.
CMD npm startThe good version uses exec form, so the application process receives termination signals directly.
The bad version uses shell form. The shell can become PID 1 and make signal forwarding and graceful shutdown less predictable.