Docker Containers Introduction
2026-03-30·10 min read·Backend
What is Docker?
Docker packages applications with their dependencies into lightweight, portable containers. Containers share the host OS kernel, making them faster (millisecond startup) and more efficient (MB vs GB) than virtual machines.
Core Concepts
- Image: Read-only template with application code and dependencies
- Container: Running instance of an image
- Dockerfile: Script to build images
- Docker Hub: Registry for sharing images
Basic Commands
docker pull nginx
docker run -d -p 80:80 nginx
docker ps
docker exec -it container_id /bin/bash
Dockerfile Example
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]