DOCKER BASIC
🐳 Docker – Basic Notes
1️⃣ Docker Kya Hai?
Definition:
Docker → Platform jo applications ko container me run karne ke liye use hota hai.
Important Points:
- Container → Lightweight, isolated environment
- Platform-independent → “Works everywhere”
- Easy deployment & scalability
2️⃣ Docker Features
- Containerization → Apps + dependencies
- Portability → Same environment anywhere
- Isolation → One container crash → baki safe
- Version control → Docker images
3️⃣ Docker Installation
- Install Docker Desktop: https://www.docker.com/get-started
- Check installation:
docker --version
4️⃣ Docker Basics Commands
| Command | Use |
|---|---|
docker run hello-world | Test Docker installation |
docker ps | Running containers |
docker ps -a | All containers |
docker images | List images |
docker rmi <image> | Delete image |
docker stop <container> | Stop container |
docker start <container> | Start container |
5️⃣ Docker Images & Containers
- Image → Template / blueprint
- Container → Running instance of image
docker pull nginx # Download image
docker run -d -p 80:80 nginx # Run container
6️⃣ Dockerfile (Create Image)
# Use base image
FROM node:18
# Set working directory
WORKDIR /app
# Copy files
COPY package*.json ./
RUN npm install
COPY . .
# Run app
CMD ["node", "server.js"]
- Build image:
docker build -t myapp . - Run container:
docker run -p 5000:5000 myapp