
10 Docker & Kubernetes Commands That Every DevOps Engineer Uses Daily
I've been working with Docker and Kubernetes in production for years. Out of the 70+ commands I use regularly, these 10 come up every single day . Here's each one with real examples, when to use them, and pro tips that took me way too long to figure out. 🐳 Docker Commands 1. docker build --target — Multi-Stage Builds What it does: Builds only a specific stage from a multi-stage Dockerfile, so your production image stays tiny. # Dockerfile FROM node:20 AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM node:20-alpine AS production WORKDIR /app COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules CMD ["node", "dist/index.js"] # Build only the production stage docker build --target production -t myapp:latest . # Build only the builder stage (for testing) docker build --target builder -t myapp:test . When to use: Every production build. Your images go from 1GB+ to under 200MB. 💡 Pro tip: Use --target builder in CI t
Continue reading on Dev.to Tutorial
Opens in a new tab

