On Linux, Docker leans on three kernel features. Namespaces give each container its own isolated view of process IDs, network interfaces, mount points, and hostnames, so a process inside thinks it owns the machine. Control groups, called cgroups, cap how much CPU, memory, and I/O a container can use. Union filesystems like OverlayFS stack the read-only image layers and the writable container layer into one view.
Images are built layer by layer. Each instruction that changes files in a Dockerfile, such as RUN apt-get install or COPY, creates a new layer that is cached and content-addressed by a SHA-256 hash. If a layer has not changed, Docker reuses the cache and skips the work, which is why a rebuild after a one-line code change finishes in seconds instead of minutes. Layers are also shared across images, so ten images built on the same base only store that base once.
On macOS and Windows there is no Linux kernel, so Docker Desktop runs a lightweight Linux VM in the background and your containers run inside it. The day-to-day commands are the same: docker build, docker run, docker push to a registry like Docker Hub, and docker pull to fetch an image somewhere else.