Skip to content

Commit 6acd54c

Browse files
committed
📝 Docker notes / virtualization
1 parent 1e6228e commit 6acd54c

20 files changed

Lines changed: 978 additions & 2680 deletions

www/.claude/rules/zettelkasten.mdc

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,58 @@ alwaysApply: false
66
# Zettelkasten: atomic notes for learning and reference
77

88
## Structure
9-
- Template: 🗓️ created datetime (DDMMYYYY HHmm), h1 title, content, References
9+
- Template: 🗓️ datetime (DDMMYYYY HHmm), h1 title, content, References
1010
- Filename = h1 title (snake_case)
1111
- One atomic concept per note
12-
- Organized by topic subdirectories (backend, frontend, infrastructure, etc.)
1312

14-
## Writing Style
15-
- **Core Concept**: Point form bullets when multiple aspects, one sentence if single aspect
16-
- Structure: **Core Concept → Why → When to Use → Trade-offs**
17-
- Short sentences. Bullets. No fluff. Cut ruthlessly.
18-
- Minimize analogies (only if genuinely clarifying)
19-
- Focus on concepts, not code (unless cheatsheet requested)
13+
## Content
2014

21-
## Content Requirements
15+
**Opening (required):**
16+
- **What it is**: Clear definition (1-2 sentences)
17+
- **Problem it solves**: Why this concept exists
2218

23-
**Must have:**
24-
- Core Concept
25-
- Why it matters (1-2 sentences)
19+
**Body (use if relevant):**
2620
- When to use / when not to use
27-
- Trade-offs
28-
29-
**Optional:**
3021
- Key distinctions (A vs B)
31-
- Common pitfalls
32-
- Comparisons
33-
- Common patterns (conceptual only)
22+
- Trade-offs or gotchas
23+
- How it works (high-level only)
24+
25+
**Style:**
26+
- Point form by default (bullet points, short statements)
27+
- Use h3 headings for subsections instead of bolded items
28+
- Bold key terms on first mention
29+
- Cut ruthlessly - details only if they aid understanding
30+
- No historical background unless it explains WHY
31+
- No obvious explanations
3432

35-
**Only if user asks for cheatsheet:**
36-
- Quick Reference (syntax/code examples)
37-
- Implementation examples
38-
- Configuration snippets
33+
## Formatting
3934

40-
**Forbidden:**
41-
- Excessive analogies or mental models
42-
- Historical background (unless explains WHY)
43-
- Code examples (unless cheatsheet requested)
44-
- Obvious explanations
35+
**Headings:**
36+
- h2 for main sections, h3 for subsections
37+
- Never use h4+
38+
- Use natural headings (not generic "Why", "When")
39+
- Prefer h3 subsections over bolded list items for structure
4540

46-
## Linking
47-
- Link inline with explicit relationship: "This builds on [[prerequisite]] because..."
41+
**Tables:**
42+
- Definitions of related terms
43+
- Comparisons
44+
- Structured data
45+
46+
**Links:**
47+
- Inline naturally: "See [[other_note]] for X"
48+
- NO "related to X because..." explanations
4849
- NO "Related Concepts" sections
4950
- Link only when: prerequisite, contrast, or logical next step
5051

51-
## Formatting
52-
- h2-h3 for sections
53-
- Bold key terms on first mention
54-
- Tables for comparisons
55-
- Admonitions sparingly (max 2): `ad-warning`, `ad-danger`, `ad-example`
56-
57-
## Accuracy
58-
- Verify facts before writing
59-
- Search credible sources when uncertain
60-
- Only link to notes that exist
61-
- Cite sources for complex information
52+
**Admonitions:**
53+
- Max 2 per note
54+
- Types: `ad-warning`, `ad-danger`, `ad-example`
55+
- Use for: common pitfalls, critical gotchas, important examples
56+
- Keep concise (1-2 sentences)
57+
58+
**References:**
59+
- Only verified sources at bottom
60+
61+
## Code/Implementation
62+
- Default: concepts only, no code
63+
- If user asks for cheatsheet: add Quick Reference section with syntax/examples

www/.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(mkdir:*)"
5+
],
6+
"deny": [],
7+
"ask": []
8+
}
9+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
🗓️ 12112024 0930
2+
3+
# virtualization
4+
5+
**What it is:**
6+
- Technology that creates isolated virtual versions of computing resources
7+
- Abstracts physical hardware from software
8+
- Enables multiple operating systems or applications to run on single physical machine
9+
10+
**Problem it solves:**
11+
- Running multiple workloads on dedicated hardware is wasteful and inflexible
12+
- Without virtualization: need separate physical machines for each application
13+
- Result: Poor resource utilization, high costs, difficult migration
14+
15+
## Hardware vs OS-level Virtualization
16+
17+
**Hardware virtualization (VMs):**
18+
- Each virtual machine runs complete OS with own kernel on top of hypervisor
19+
- Full isolation between VMs
20+
- Heavier resource overhead
21+
22+
**OS-level virtualization (containers):**
23+
- Multiple isolated user spaces share same kernel
24+
- Lightweight and fast
25+
- Can only run applications compatible with host kernel
26+
- See [[docker_overview]] for container details
27+
28+
Key distinction: VMs virtualize hardware (can run different OS types), containers virtualize OS (share kernel).
29+
30+
## Hypervisor Types
31+
32+
**Type 1 (Bare Metal):**
33+
- Runs directly on hardware without host OS
34+
- Examples: VMware ESXi, Hyper-V, KVM, Xen
35+
- Better performance, lower overhead
36+
- Used in production data centers and cloud infrastructure
37+
38+
**Type 2 (Hosted):**
39+
- Runs on top of host OS
40+
- Examples: VirtualBox, VMware Workstation, Parallels
41+
- Easier to set up, more overhead
42+
- Used for development and testing
43+
44+
Pattern: Type 1 for production workloads and server consolidation. Type 2 for development and desktop virtualization.
45+
46+
## VMs vs Containers
47+
48+
**VMs:**
49+
- Full OS per instance, GBs in size, minutes to start
50+
- Complete kernel isolation
51+
- Use when need different OS types on same hardware, maximum security isolation, or legacy applications requiring specific OS versions
52+
53+
**Containers:**
54+
- Shared kernel, MBs in size, seconds to start
55+
- Process-level isolation
56+
- Use when application-level isolation sufficient, need fast startup/scaling, want resource efficiency, or building microservices
57+
- Covered in [[docker_overview]]
58+
59+
Pattern: VMs for OS isolation, containers for application isolation. Or combine: run containers within VMs for both levels.
60+
61+
## When to Use VMs
62+
63+
Use for:
64+
- Multiple OS environments on single hardware
65+
- Strong isolation between workloads for security
66+
- Legacy application support requiring specific OS versions
67+
- Disaster recovery with snapshots and migration
68+
- Resource consolidation to reduce hardware costs
69+
- Dev/test environments isolated from production
70+
71+
Skip for:
72+
- Performance-critical applications where overhead unacceptable
73+
- Simple application isolation (containers more lightweight)
74+
- Resource-constrained environments
75+
- Bare-metal performance required (GPUs, high-frequency trading)
76+
77+
## Key Benefits and Trade-offs
78+
79+
**Benefits:**
80+
- Complete OS isolation
81+
- Run different OS types on same hardware
82+
- Strong security boundaries
83+
- Hardware independence
84+
- Easy backup/recovery with snapshots
85+
- Live migration between hosts
86+
87+
**Drawbacks:**
88+
- Resource overhead (each VM runs full OS)
89+
- Slower startup times
90+
- Larger storage requirements
91+
- More complex management
92+
- License costs for guest operating systems
93+
94+
## Virtualization in Cloud Computing
95+
96+
Cloud IaaS built on virtualization:
97+
- AWS EC2, Azure VMs, Google Compute Engine
98+
- On-demand virtual machines without managing physical hardware
99+
- Cloud provider handles hypervisor layer
100+
101+
For container workloads in cloud, see [[docker_orchestration]] for managing containerized applications at scale.
102+
103+
## Common Pitfalls
104+
105+
```ad-warning
106+
**Over-provisioning VMs**: Allocating too many resources (CPU, RAM) wastes capacity. VMs don't use what they're allocated, they use what they need. Monitor actual usage and right-size allocations.
107+
```
108+
109+
```ad-danger
110+
**VM sprawl**: Unmanaged VM creation leads to wasted resources and security risks. Implement VM lifecycle policies, regular audits, and automated cleanup of unused VMs.
111+
```
112+
113+
---
114+
115+
## References
116+
117+
- https://www.vmware.com/topics/glossary/content/virtualization.html
118+
- https://www.redhat.com/en/topics/virtualization/what-is-virtualization
119+
- https://aws.amazon.com/what-is/virtualization/
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
🗓️ 11112024 1450
2+
3+
# docker_compose
4+
5+
**What it is:**
6+
- Tool for defining and running multi-container applications
7+
- Uses YAML configuration file
8+
- Single command starts entire application stack with dependencies, networks, volumes
9+
10+
**Problem it solves:**
11+
- Running multi-container apps with `docker run` means typing long commands for each service
12+
- Must manually create networks, manage startup order, remember all flags
13+
- Compose replaces this with declarative config file and simple commands
14+
15+
## Structure
16+
17+
A `docker-compose.yml` defines:
18+
19+
### Services
20+
- Containers to run
21+
- Each service specifies image/build context, ports, environment variables, dependencies, health checks
22+
23+
### Networks
24+
- How containers communicate
25+
26+
### Volumes
27+
- Persistent data
28+
29+
## When to Use
30+
31+
Use for:
32+
- Multi-container applications (app + database + cache)
33+
- Local development environments with multiple services
34+
- Integration testing requiring full stack
35+
- Small single-host production deployments
36+
37+
Skip for:
38+
- Single containers (just use `docker run`)
39+
- Production at scale (use [[docker_orchestration]] like Kubernetes)
40+
- Multi-host deployments needing auto-scaling and rolling updates
41+
42+
## Dependency Management
43+
44+
`depends_on` controls startup order:
45+
- Only waits for containers to start, NOT for services to be ready
46+
- Combine with `condition: service_healthy` to wait for [[docker_healthcheck]] to pass
47+
- Without health checks, app might try connecting to database that's still initializing
48+
49+
## Environment Variables and Config
50+
51+
Configuration options:
52+
- Set inline in YAML
53+
- Load from `.env` files
54+
- Substitute from host environment
55+
- Mount config files via volumes
56+
57+
Pattern: Use environment variables for secrets and runtime config, mount files for complex configuration.
58+
59+
## Compose vs Orchestration
60+
61+
Differences:
62+
- Compose: Single-host, development-focused
63+
- [[docker_orchestration]]: Multi-host, production-grade
64+
- Compose orchestrates containers but doesn't manage clusters
65+
- Many start with Compose for dev, move to Kubernetes for prod
66+
67+
For production needing auto-scaling, rolling updates, self-healing: use orchestration platforms.
68+
69+
## Common Pitfalls
70+
71+
```ad-warning
72+
**Ignoring health checks**: Using `depends_on` without health checks means dependent services start before dependencies are ready. Always add [[docker_healthcheck]] to services that need startup time.
73+
```
74+
75+
```ad-danger
76+
**Using Compose for production scale**: Compose has no auto-scaling, no rolling updates, no multi-host support. Great for single-host deployments but not designed for production scale. Use [[docker_orchestration]] platforms instead.
77+
```
78+
79+
---
80+
81+
## References
82+
83+
- https://docs.docker.com/compose/
84+
- https://docs.docker.com/compose/compose-file/

0 commit comments

Comments
 (0)