- Knowledge
- technology
- OOP
- Tips
- Programming
- Tips
- Tutorial
- SEO
- Ranking
- Knowledge
- Special Day
- Seo
- Bug
- Data science
- Seo
- artificial intelligence
- Machine Learning
- Robotics
- happyNewYear2021
- newYearEve
- 2021
- Automation
- Smart Home
- Career
- Best Practices
- Git
- Logging
- Web Fundamentals
- DNS
- HTTPS
- Performance
- AI Tools
- ChatGPT
- Claude
- Gemini
- Laravel
- Eloquent
- MySQL
- HTTPS
- TLS
- Web Security
- Certificates
- Developer Life
- Debugging
- Docker
- DevOps
- Transactions
- Queues
- LLMs
- AI
- AI Coding
- Developer Tools
- React Native
- Expo
- Kate PMS
- Mobile Apps
- Laravel
- Authentication
- Sanctum
- Cookies
- API Design
- Payments
- Idempotency
- DeepSeek
- Open Source AI
- LLMs
- AI News
- Git
- Version Control
- AI Coding
- Prompting
- PHP
- Checklist
- MCP
- AI Agents
- OpenAI
- Architecture
- Microservices
- Modular Monolith
- Estimation
- Developer Life
- Project Planning
- Humour
- OAuth
- OpenID Connect
- Authentication
- Embeddings
- Vector Search
- RAG
- pgvector
- OpenAI
- GPT-4.1
- Codex CLI
- Events
- Testing
- Clean Code
- Maintainability
- Code Review
- Webhooks
- API
- Security
- Claude Code
- Workflow
- AI
- LLM
- Prompt Injection
- Mobile
- React
- Networking
- TCP
- UDP
- HTTP/3
- CLAUDE.md
- AWS
- Cloud Security
- Backups
- PHPUnit
- Software Engineering
- Leadership
- Communication
- RAG
- Embeddings
- AI Engineering
- IT Infrastructure
- Networking
- Access Control
- CI/CD
- GitHub Actions
- Gemini CLI
- Claude Code
- JavaScript
- Async/Await
- Node.js
- Promises
- Security
- Cryptography
- Passwords
- MySQL
- Database
- Vibe Coding
- Software Quality
- DNS
- Code Reading
- Onboarding
- Productivity
- Background Jobs
- Developer Humour
- Estimates
- Dev Life
- JWT
- o3-mini
- DeepSeek R1
- Rate Limiting
- Kate PMS
- E-Signing
- Audit Trail
- REST
- GraphQL
- API Design
- Laravel 12
- Upgrade Guide
- Open Source
- Self-Hosting
- Task Scheduling
- Cron
- Secrets
- CORS
- PHP
- PHP-FPM
- OPcache
- GitHub Copilot
- Software Architecture
- Engineering
- TypeScript
- JavaScript
- Type Safety
- AI Security
- React Native
- Product Design
- AI Agents
- Kiro
- Queues
- Redis
- RabbitMQ
- AWS SQS
- Nginx
- Apache
- GPT-5
- gpt-oss
- Clean Code
- Architecture
- Naming
- Documentation
- Career
- ADR
- Teamwork
- Supply Chain
- Kate HRM
- HR Software
- Permissions
- System Design
- Pagination
- SSH
- Linux
- Big O
- Databases
- Laravel Boost
- MCP
- Developer Skills
- Validation
- Databases
- Indexes
- Code Quality
- Deployment
- Developer Humour
- Feature Flags
- Code Review
- Pull Requests
- Docker
- Cursor
- Authorization
- RBAC
- Gemini
- Long Context
- PHP 8.4
- Caching
- Dependency Injection
- Web Performance
- Browser
- CSS
- Database
- Migrations
- ChatGPT
- AI for Developers
- Monitoring
- On-Call
- REST
- Backend
- SQL
- NoSQL
- Database Design
- Coding Agents
- Claude 4
- API Resources
- REST API
- Load Balancing
- Scaling
- AWS
- AI Tools
- Claude
- Sora 2
- CTE
- 2FA
- TOTP
- Programming Languages
- Prompts
- Developer Workflow
- API Gateway
- APIs
- Passport
- API Auth
- Learning
- Burnout
- Developer Growth
- Web Development
- SEO
- Kate Mall
- ChatGPT Atlas
- Agent Skills
- Middleware
- Laravel 12
- Collections
- Context Window
- Monitoring
- Commit Messages
- Self Review
- Growth
- Regex
- Programming Basics
- Text Processing
- Database Design
- Normalization
- Linux
- Server Security
- Linux Foundation
- Open Standards
- Legacy Code
- Documentation
- AI Workflow
- File Uploads
- Test Data
- Hashing
- Performance
- Caching
- Enums
- Scope Creep
- Estimation
- Codex
- Gemini CLI
- Timezones
- Carbon
- Bugs
- PHP 8.5
- Gemini 3
- GPT-5.1
- Data Integrity
- Event Loop
- Async
- Opus 4.5
- AI Models
- React
- Forms
- Frontend
- Backups
- AI Images
- DALL-E
- Midjourney
- Race Conditions
- Concurrency
- Legacy Code
- Refactoring
- Senior Engineer
- Scope
- LLM
- CDN
- Web
- Sub-Agents
- Soft Deletes
- Audit Log
- Concurrency
- AI Learning
- NestJS
- AI Evals
- Policies
- SPF DKIM DMARC
- Unicode
- UTF-8
- Knowledge Graph
- Value Objects
- Technical Debt
- Feature Flags
- Laravel Pennant
- Deployment
- Copilot
- Composer
- Dependencies
- Artisan
- Automation
- AWS S3
- Object Storage
- Cloud
- Small Language Models
- Ollama
- Production
- Sessions
- HTTP
- Mentoring
- SQL
- Virtual Machines
- Web Development
- HTTP/2
- QUIC
- Web Performance
- AI Integration
- LLM API
- SOLID
- OOP
- Hosting
- Serverless
- Merge Conflicts
- Temperature
- AI Development
- Reverse Proxy
- Nginx
- Infrastructure
- Verification
- Passkeys
- WebAuthn
- Teams
- Communication
- Stakeholders
- Monorepo
- CI/CD
- Versioning
- JSON Schema
- Livewire
- Inertia
- Meetings
- Distributed Systems
- Privacy
- Full-Stack
- T-Shaped Skills
- Money
- Notifications
- Web Security
- HTTP Headers
- CSP
- Function Calling
- Load Testing
- k6
- Data Extraction
- Debugging
- WebSockets
- SSE
- Real-Time
- Laravel Reverb
- Infrastructure as Code
- Terraform
- Side Projects
- Laravel Pint
- OpenAPI
- Swagger
- UX
- Multimodal
- Jest
- Pair Programming
- APIs
- Rate Limiting
- Resilience
- Dev Humour
- Design Tokens
- JWT
- API Keys
- Sessions
- PHPStan
- Rector
- Incidents
- Reporting
- Dashboards
- Zero Trust
- IAM
- Search
- Laravel Scout
- Junior Developers
- Mentoring
- Images
- WebP
- AVIF
- Bug Reports
- Let's Encrypt
- Design Docs
- Software Design
- Observers
- Replication
- Accountability
- Data Structures
- Reliability
- LLM Memory
- Error Handling
- Payments
- Payment Gateway
- Webhooks
- PCI DSS
- Observability
- OpenTelemetry
- Personal Brand
- Writing
- Conventions
- Dates
- Scheduling
- Disaster Recovery
- Compression
- Brotli
- Deadlines
- Developer Habits
- State Machines
- Tech Roles
- UUID
- ULID
- Horizon
- Planning
- Engineering Culture
- Ownership
- Soft Skills
- Socialite
- Cost Control
- Collations
- Unicode
- Octane
- PostgreSQL
Containers vs Virtual Machines: What's Actually Different Under the Hood
About Post
Ask ten developers what a container is and at least eight will say "a lightweight virtual machine". It's a handy shortcut. It's also wrong in exactly the places that matter: security, performance, and why your Docker setup behaves differently on a Mac than on a Linux server.
Here's a one-line experiment that shows the real difference. On a Linux machine with Docker, run:
uname -r # the host's kernel version
docker run --rm alpine uname -r # the container's kernel version
Both commands print the same thing. The container is running a different Linux distribution, Alpine, but it's using your kernel. A virtual machine would print its own. That one fact explains almost everything else.
The mental model: houses vs flats
A virtual machine is a detached house. It has its own foundations, plumbing and electricity. Complete independence, but every house needs all of that built from scratch.
A container is a flat in an apartment building. Your own front door, your own furniture, your own lock. But you share the foundations, the water main and the wiring with everyone else in the building.
The shared foundation, in computing terms, is the operating system kernel.
How a virtual machine works
A VM emulates an entire computer. A piece of software called a hypervisor sits between the hardware and the VMs, handing each one virtual CPUs, memory, disks and network cards.
Each VM then boots a complete operating system, with its own kernel, on that virtual hardware. As far as the guest OS knows, it owns a real machine.
- Type 1 hypervisors run directly on the hardware: KVM, Xen, VMware ESXi, Hyper-V. Cloud providers use this kind; an EC2 instance is a VM.
- Type 2 hypervisors run as an application on your desktop OS: VirtualBox, VMware Workstation, Parallels.
Modern CPUs have hardware support for virtualisation, so VMs run at close to native speed. The cost isn't so much speed as weight: every VM carries a full OS, which takes memory, disk space, and boot time.
How a container works
A container doesn't emulate anything. It's a normal process on the host, running on the host's kernel, with two Linux kernel features wrapped around it:
- Namespaces control what the process can see. It gets its own view of process IDs, network interfaces, mount points and hostname. Inside the container, your app thinks it's PID 1 on a machine of its own.
- Control groups (cgroups) control what the process can use: how much CPU, memory and I/O it's allowed.
Add a layered filesystem for the image, and that's essentially Docker: an isolated, resource-limited process with its own files. Since there's no OS to boot, a container starts about as fast as the process inside it.
| Virtual machine | Container | |
|---|---|---|
| What's isolated | A whole computer, own kernel | A process, shared host kernel |
| Isolation boundary | Hypervisor (strong) | Kernel features (good, but thinner) |
| Startup | Boots an OS | Starts a process |
| Size | Full OS image | App plus its dependencies |
| Different OS than host? | Yes, any OS | Same kernel family only |
| Typical use | Servers, multi-tenant isolation, other OSes | Packaging and shipping apps |
Three things that surprise people
1. Docker on your Mac or Windows laptop is running a VM
Linux containers need a Linux kernel. macOS and Windows don't have one, so Docker Desktop quietly runs a small Linux VM (on Windows, typically through WSL 2) and runs your containers inside it. That's why file syncing between your laptop and a container can feel slow there, and why it's fast on a Linux server.
2. Containers usually run inside VMs anyway
In the cloud, the question is rarely "containers or VMs". Your containers run on a VM: an EC2 instance, a Kubernetes node, a managed container service. The VM gives isolation from other customers; the containers give you a clean way to package and deploy your app.
3. Root in a container can be closer to root on the host than you think
Because the kernel is shared, the isolation is only as strong as the kernel's features and your configuration. A kernel vulnerability, a container running as root with extra privileges, or mounting the Docker socket into a container can all let a process reach the host. That's why good images run as a non-root user and avoid --privileged.
The one-sentence version: a VM virtualises the hardware, a container virtualises the operating system. Everything else, speed, size, security and portability, follows from that.
The middle ground: microVMs and sandboxed runtimes
For running untrusted code, like other customers' functions, the industry has built options in between. Firecracker, created by AWS for Lambda and Fargate, starts tiny VMs fast enough to feel like containers. gVisor, from Google, puts a user-space kernel between the container and the host. Kata Containers runs each container inside a lightweight VM.
You probably won't configure these yourself, but they're worth knowing about. They exist precisely because a shared kernel isn't always enough isolation.
So which should you use?
Reach for containers when:
- You want the same environment in development, CI and production.
- You run several services (app, queue worker, Redis) and want them packaged consistently.
- You deploy often and want fast, repeatable releases.
Reach for VMs when:
- You need strong isolation between tenants or untrusted workloads.
- You need a different operating system or a specific kernel version.
- You're running something that expects a full machine, like legacy software or a desktop environment.
In practice, most web teams use both: VMs as the servers, containers as the way apps get onto them.
The takeaway
A container isn't a small VM. It's a process with blinkers on, sharing the host's kernel. That's why it starts instantly and packs densely, and also why it needs a bit more security care than a VM.
Run that uname -r experiment once and the distinction sticks for good.
Where do you draw the line in your own setup: what runs in containers, and what still gets its own VM?

Be first to comment it...