Dockerfile बिल्डर
Dockerfile बनाएं।
Presets:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]Best Practices
- • Use specific image tags instead of :latest for reproducibility
- • Combine multiple RUN commands with && to reduce layers
- • Copy package.json first, then npm install, then copy source for better caching
- • Use multi-stage builds for smaller production images
- • Run as non-root user for security
Dockerfiles - तकनीकी विवरण
A Dockerfile is a text file containing instructions to build a Docker image. Each instruction creates a layer, so optimizing the order and combining commands reduces image size and build time.
कमांड-लाइन विकल्प
# Build Docker image\ndocker build -t my-app .\n\n# Run container\ndocker run -p 3000:3000 my-app\n\n# Multi-stage build\n# See Dockerfile reference for advanced patterns