๐ DevOps Docker Training Notes
๐ Day 1 โ Traditional vs Containerized Deployment
๐๏ธ Traditional Deployment / Old Deployment
๐ฅ๏ธ Virtualized Deployment
โ VM Disadvantages:
- Each VM needs its own OS โ high CPU, memory, and storage consumption.
- Higher cost for enterprise OS editions.
- Can deploy multiple applications in one VM, but no isolation.
- Middleware conflicts โ can't run multiple versions (e.g., Java 11 vs Java 17).
- Environment inconsistencies (e.g., config files, env variables).
- AMIs can help maintain consistency but still require full OS per VM.
๐ด Summary:
- Each VM โ full OS โ high cost and compute usage.
- Middleware/software compatibility issues.
- No proper isolation for apps within same VM.
๐ฆ Containerized Deployment
๐งฑ What is a Container?
- Includes: App code + dependencies + config files + env variables.
- Containers share the host OS (no separate OS required).
- Each container has its own OS libraries โ interacts with OS kernel.
- Multiple containers can run on a single host OS.
๐ ๏ธ Use Cases:
- Applications
- Databases
- Tools (e.g., Jenkins, Nexus)
๐ Isolation:
- Container runtime provides:
- Separate process space
- Network space
- Storage space
- Mount space
- High CPU โ container may hang.
- Out of memory โ container is killed by OS (via cgroups).
๐ Day 2 โ Container Types and Tools
๐งฐ Container Use Cases:
๐ Web Servers:
- HTTPD, NGINX, HAProxy
๐ป Application Servers:
- Java, Python, Node.js, JBoss, Tomcat, Go
๐๏ธ Database Servers:
- MySQL, Oracle, MongoDB, PostgreSQL, Couchbase, Cassandra
โ๏ธ Messaging Servers:
- Kafka, RabbitMQ
๐ ๏ธ Other Tools:
- Jenkins, Nexus, SonarQube
๐ณ Containerization Tools:
๐ง Runtime Tools:
- Docker
- Podman
- containerd
๐ฆ Orchestration Tools:
- Docker Swarm
- Kubernetes
- OpenShift
๐ณ Docker Editions:
- Community Edition โ Free
- Enterprise Edition โ Paid
- DTR: Docker Trusted Registry
- UCP: Universal Control Plane (GUI for managing containers)
Docker images built on any OS or flavor (RHEL, Ubuntu, etc.) can be stored in registries like Nexus/ECR and run on any platform.
๐ Day 3 โ Docker Setup & Runtime
๐ Container Limits
- Number of containers depends on available CPU and RAM.
๐งฉ OS Compatibility:
- Best OS for Docker: Ubuntu
- Docker not compatible with RHEL in production (no support).
๐ง Docker Daemon
- Background service managing:
- Docker images
- Containers
- Networks
- Volumes
๐งฐ Installing Docker on Ubuntu (AWS):
```bash sudo apt update -y sudo apt install docker.io -y sudo service docker start docker info Regular users will face permission issues.
โ Add User to Docker Group: bash Copy code sudo usermod -aG docker $USER
OR
sudo usermod -aG docker ubuntu Logout and SSH again. Then run:
bash Copy code docker ps ๐ Class 4 โ Docker Registries ๐ Docker Image Storage ๐ Secure Registries: Use HTTPS for registries like Nexus, ECR.
Docker Hub provides only one private repo โ limited use in real-time.
๐ Docker Concepts Registry: Central image storage.
Repository: Collection of related images (usually different versions).
๐ Image Pull Behavior: If registry not mentioned:
Docker checks local
Else pulls from Docker Hub
โ๏ธ Create Repos in Nexus / ECR ๐น ECR: Image format: registryURL/repository:tag
๐น Nexus: Go to Settings โ Repositories โ Create Repository โ Docker (hosted)
Use port 8083 for reverse proxy
โ ๏ธ Insecure Registry Configuration: If using HTTP (insecure) registry:
Edit the daemon config:
bash Copy code sudo vi /etc/docker/daemon.json Add:
json
Copy code
{
"insecure-registries": ["
๐ Day 5 โ Docker Image Build & Deployment โ Docker Advantages: Easy to share & deploy using Docker images
Lightweight โ shares host OS, saves resources
Version management
Middleware compatibility solved
๐ ๏ธ Docker Build Server Setup: Install the following on Docker build server:
Docker
Git
Maven
Java
Don't write Dockerfiles directly on Docker server.
๐ Real-Time Workflow: Write Dockerfile in project repo.
Commit & push to GitHub.
Clone repo to Docker build server.
Build image and push to registry (ECR/Nexus).
Another deployment server pulls image and runs container.
๐ Build and deploy happen on different servers.
๐ Accessing the Application: Expose container ports to access apps via browser or API.
๐ Day 6 โ Tagging & ECR Authentication ๐ท๏ธ Docker Image Tagging If image was created without proper name (e.g., missing registry/repo), use:
bash Copy code docker tag oldimagename:tag newregistry/repository:newtag You can see multiple names, but the Image ID remains the same.
๐ Docker Login to ECR To authenticate with ECR registry:
Go to ECR repo
Click View Push Commands
Use the first command (requires AWS CLI):
bash
Copy code
aws ecr get-login-password --region
๐ก๏ธ ECR Security Features: ๐ Tag Immutability: Prevents overwriting existing image versions.
Enable this to ensure image stability.
Same concept applies to Nexus.
๐ Scan on Push: Automatically checks for vulnerabilities when image is pushed.
๐ KMS Encryption: Encrypt images stored in ECR using AWS KMS.
๐ IAM Role & AWS CLI Access โ For Docker Build Server: Create and attach IAM policy with full ECR access.
Install AWS CLI.
Authenticate before push.
๐ Note: Token is valid for 4 hours โ must re-authenticate frequently.
โ For Deployment Server: Install AWS CLI.
Attach read-only IAM policy.
Authenticate and pull images.
yaml