Quick Start
Learn core Docker concepts and containerization patterns. This Quick Start teaches essential Docker skills.
🎯 What You’ll Learn
By the end of this tutorial, you’ll understand:
- Images and containers
- Dockerfiles and building images
- Docker Compose for multi-container apps
- Volumes and networking
📋 Prerequisites
- Docker installed (see Initial Setup)
📦 Dockerfile
Create Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]Build:
docker build -t myapp .
docker run -p 3000:3000 myapp🔧 Docker Compose
Create docker-compose.yml:
version: "3.8"
services:
web:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
depends_on:
- db
db:
image: postgres:15
environment:
POSTGRES_PASSWORD: secret
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:Run:
docker-compose up -d
docker-compose ps
docker-compose logs
docker-compose down💾 Volumes
docker volume create mydata
docker run -v mydata:/data alpine🌐 Networking
docker network create mynetwork
docker run --network mynetwork --name app1 nginx
docker run --network mynetwork --name app2 alpine ping app1✅ Next Steps
You now understand Docker essentials!
- Try the examples: Build images and run containers
- Explore By Example: Docker By Example
🎯 Self-Assessment
After completing this Quick Start, you should be able to:
- Write Dockerfiles
- Build and run containers
- Use Docker Compose
- Work with volumes and networks
Last updated