Udemy Docker Advanced PDF
Udemy Docker Advanced PDF
Udemy Docker Advanced PDF
Advanced
DOCKER ADVANCED
A deeper look into Docker
• Lecture
• Demos
• Coding Exercises
• Assignment
PRE-REQUISITES
❑
✓D ocker Over view ❑ Docker Concepts in Depth
❑
✓Ruunni ng
g Docker Containers ❑ Docker For Windows
❑
✓Crea
a tin
ng a Docker Image ❑ Docker Service
❑
✓D ocker Compose ❑ Docker Swarm
❑
✓Docker Swarm ❑ Overlay Networks
❑
✓Neet working in Docker ❑ Load Balancing
❑ CI/CD Integration
DOCKER STORY
• 64-bit operating
• Windows 7 or higher.
• Virtualization is enabled
• Oracle Virtualbox
• Docker Engine
• Docker Machine
• Docker Compose
• Kitematic GUI
2. DOCKER FOR WINDOWS
Kernel Kernel
Base Images:
• Nano Server
Support
• Windows Server 2016
• Nano Server
• Windows 10 Professional and Enterprise (Hyper-V Isolated Containers)
DEMO
DOCKER ENGINE
Docker CLI
REST API
InterProcess
NAMESPACE - PID
Linux System
PID : 1
PID : 2
PID : 3
Child System (Container)
PID : 4
PID : 5 PID : 1
PID : 6 PID : 2
CGROUPS
Linux System
CPU Memory
/var/lib/docker
aufs
containers
image
volumes
LAYERED ARCHITECTURE
Dockerfile Dockerfile2
FROM Ubuntu FROM Ubuntu
RUN apt-get update && apt-get –y install python RUN apt-get update && apt-get –y install python
RUN pip install flask flask-mysql RUN pip install flask flask-mysql
Read Write
Container Layer
Layer 6. Container Layer
Read Only
Layer 5. Update Entrypoint with “flask” command
Layer 4. Source code
Read Write
Container Layer
temp.txt
Read Only
/var/lib/mysql /var/lib/mysql
data_volume mysql
/var/lib/docker/volumes /data
Read Only
mysql – image layer
Docker Host
STORAGE DRIVERS
• AUFS
• ZFS
• BTRFS
• Device Mapper
• Overlay
• Overlay2
DOCKER SWARM
Docker Swarm
MySQL
Container
docker swarm init docker swarm join docker swarm join docker swarm join
Leader
Docker Host Docker Host Docker Host
L
L
DISTRIBUTED CONSENSUS - RAFT
DB
D
Instruction
DB DB
HOW MANY MANAGER NODES?
• Docker Recommends – 7 Managers
• No limit on Managers
4 3 1
5 3 2
6 4 2
N-1
7 4 3 Fault Tolerance of N =
2
ODD OR EVEN?
1 1 0
2 2 0
3 2 1
4 3 1
5 3 2
7 O
O6 4 2
7O 4 3
WHAT HAPPENS WHEN IT FAILS?
Web Server Web Server Web Server Web Server Web Server
Docker Host Docker Host Docker Host Docker Host Docker Host
docker node promote
Web Server
Docker Host
Docker Swarm
TASKS
docker service create –replicas=3 my-web-server
Orchestrator
Scheduler
Manager Node
Web Server
Docker Swarm
REPLICAS
docker service create –replicas=3 my-web-server
Docker Swarm
REPLICAS VS GLOBAL
docker service create --replicas=3 my-web-server
Docker Swarm
SERVICE NAME
docker service create --replicas=3 -m-yn-awmeeb-wseebr-vseerrver
Docker Swarm
SERVICE UPDATE
docker service create –replicas=3 --name web-server my-web-server
Docker Swarm
CODING EXERCISES
docker-compose.yml
services:
web:
image: “mmumshad/simple-webapp"
database:
image: “mongodb“
messaging:
image: "redis:alpine“
orchestration:
image: “ansible“
docker-compose up
DOCKER COMPOSE
docker run mmumshad/simple-webapp docker service create mmumshad/simple-webapp
docker-compose.yml docker-compose.yml
services: services:
web: web:
image: “mmumshad/simple-webapp" image: “mmumshad/simple-webapp"
database: database:
image: “mongodb“ image: “mongodb“
messaging: messaging:
image: "redis:alpine“ image: "redis:alpine“
orchestration: orchestration:
image: “ansible“ image: “ansible“
Stack
Container
Service Service
Container
Container Container
Service
Stack
STACK DEFINITION
docker service create mmumshad/simple-webapp
docker-compose.yml
services:
web:
image: "mmumshad/simple-webapp"
database:
image: "mongodb"
messaging:
image: "redis:alpine"
orchestration:
image: "ansible"
docker run ubuntu docker run Ubuntu –-network=none docker run Ubuntu --network=host
5000 5000
Web Web
Container Container
Overlay Network
10.0.9.0
Load Balancer
http://192.168.1.5:80
docker0
172.17.0.1
Docker Host
Docker Swarm
INGRESS NETWORK
80 80 80
Routin g Mesh
5000 5000
Web Web
Container Container
Host IP
mysql.connect( 172.17.0.3
mysql ) web mysql web 172.17.0.2
Container Container
172.17.0.2 172.17.0.3 mysql 172.17.0.3
docker0
DNS
Server
127.0.0.11
Docker Host
LEARN MORE
Ingress Network 10.255.0.0/16
10.255.2.139 10.255.2.140
CI/CD
Test
Feature #1 Build System Framework
Code Repository
✓ Unit Test
✓ Web UI Test
✓ Integration Test
Feature #2
Robot
Framework
BugFix #1
Continuous Integration
CD – CONTINUOUS DELIVERY/DEPLOYMENT
Production Environment
Release
Management
CI
Continuous Delivery
Continuous Deployment
CI/CD - DOCKER
Test
Framework
Build System
Code Release
Repository
my-app:1.0
Docker
Hub
Dockerfile
Robot
Framework
Docker Plugin
Continuous Integration
Continuous Delivery
PUBLIC CLOUD – DOCKER SUPPORT
docker push m
lmou
cmas
lhod
s/ my
t: 5-
0c us
00 /t om-app docker push mmumshad/my-custom-app