Junior — Middle
How can a minimal Dockerfile be created for containerizing an application?
sobes.tech AI
Answer from AI
The minimal Dockerfile for containerizing an application usually contains a base image, copying source code, and a run command. For example, for a simple Node.js application:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["node", "index.js"]
Here:
FROMspecifies the base imageWORKDIRsets the working directoryCOPYcopies files into the containerRUNinstalls dependenciesCMDsets the container's startup command
For other languages and applications, the structure is similar: base image, copying, dependency installation, and execution.