VMs vs containers — what is the difference from a networking point of view?
I understand VMs have their own OS and containers share the kernel. But what does that mean for how they attach to the network?
1 Answer
A VM carries its own full OS and gets a virtual NIC attached to a hypervisor vSwitch — from the network's perspective it's a complete host with its own MAC and IP, often bridged straight into a VLAN. A container shares the host kernel; its networking is usually a network namespace with a veth pair into a bridge on the host, commonly NAT'd behind the host's IP (that's why containers publish ports). Consequences: VMs appear individually in your ARP/MAC tables; containers frequently don't — you see the host. Scale differs too: VMs boot in seconds and cost hundreds of MB; containers start in milliseconds and cost tens, which is why microservice fleets are containers and full-OS isolation workloads stay VMs.