Middle+
What base image did you use in the Dockerfile?
sobes.tech AI
Answer from AI
In Dockerfile for applications, I usually use minimal and verified base images to ensure lightweight and security. For example:
- For Node.js applications — the official image
node:16-alpine, which is based on Alpine Linux and takes up little space. - For Python —
python:3.9-slimorpython:3.9-alpinefor compactness. - For Java —
openjdk:11-jre-slim.
Example Dockerfile for Node.js:
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
CMD ["node", "index.js"]
The choice of base image depends on size requirements, security, and compatibility with the application.