I have been running Docker in production since 2015. Here is what actually matters β not what the tutorials tell you.
Why This Matters
Docker is everywhere, but most teams run it with default settings that are insecure, slow, or wasteful. Getting the basics right saves hours of debugging later.
Prerequisites
- Docker installed (Install Docker on Ubuntu or RHEL 9)
- Basic command-line familiarity
Step-by-Step Guide
Step 1: Understand the Core Concepts
Containers are not VMs. They share the host kernel and use namespaces for isolation. Understanding this changes how you think about security, networking, and resource management.
Step 2: Write Production Dockerfiles
# Multi-stage build for minimal image
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:22-alpine
RUN addgroup -g 1001 -S app && adduser -S app -u 1001
WORKDIR /app
COPY --from=build --chown=app:app /app/dist ./dist
COPY --from=build --chown=app:app /app/node_modules ./node_modules
USER app
EXPOSE 3000
HEALTHCHECK --interval=30s CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["node", "dist/server.js"]Step 3: Configure Networking
# Create isolated network
docker network create --driver bridge app-network
# Run containers on the network
docker run -d --name api --network app-network myapi:latest
docker run -d --name db --network app-network postgres:16Step 4: Monitor and Debug
# View container resource usage
docker stats
# Inspect container details
docker inspect <container>
# View logs with timestamps
docker logs --timestamps --tail 100 <container>Common Mistakes
- Using
:latesttag β pin versions for reproducibility - Running as root β always use
USERinstruction - Not using
.dockerignoreβ bloated build contexts - Single-stage builds β unnecessarily large images
Related Resources
- Docker Cheat Sheet
- Dockerfile Best Practices
- Docker vs Kubernetes
- Podman vs Docker
- Docker Security Best Practices
About the Author
I am Luca Berton, AI and Cloud Advisor with 8 published books on automation, Kubernetes, and AI. Book a consultation to discuss your docker networking strategy.