DOCKER - 9 Conteneur vs VMs
Search the internet for a container definition and you'll quickly stumble on people comparing containers to virtual machines. There are some surface similarities, but the two concepts are fundamentally different. A container is not a VM — it is simply a process running on your operating system, scoped and restricted by the kernel. Once you internalise that, Docker becomes much easier to reason about.
A container is just a host process
Let's prove it with MongoDB. We launch a Mongo container in the background:
docker container run --name mongo -d mongo
docker container top mongo
The docker top command lists the processes running inside a specific container. For our Mongo container, you'll see a single process named mongod. Running ps aux on the host machine shows the very same mongod process in the global process table — proof that it is a regular Linux process, not something hidden inside an inaccessible virtual machine.
docker container stop mongo— stop the container;docker psno longer lists itdocker container top mongoon a stopped container returns nothingdocker container start mongoresumes it, much like resuming a suspended process
After restarting, docker ps shows it running again and docker top mongo reveals mongod alive once more. This simple demonstration is enough to anchor the right mental model: containers are restricted, namespaced processes — lightweight, fast to start, and free of the overhead of a full guest OS.
Summary
Containers are fundamentally different from virtual machines—they are restricted processes running directly on the host OS, not isolated operating system instances. This lesson clarifies the key distinction through practical Docker commands, demonstrating how to run, manage, and monitor containers (using MongoDB as an example) with docker run, docker ps, docker top, docker stop, and docker start to show containers' lightweight, process-based nature.
Key points
- Containers are processes, not virtual machines—they run directly on the host operating system without emulating an entire OS
- A container is a restricted process confined within the host OS with limited resources and isolation
- Docker provides core commands like docker ps (list running containers), docker top (view processes inside a container), docker stop, and docker start to manage container lifecycle
- When a container is stopped, its process halts but the container persists in a stopped state, similar to a suspended process
- MongoDB containerized examples demonstrate how database services run as single processes within Docker containers
FAQ
What is the main difference between a container and a virtual machine?
A container is a restricted process that runs directly on your host operating system. A virtual machine emulates an entire operating system. Containers are much lighter and faster because they don't need to virtualize the entire OS—they just isolate a process on the existing OS.
What does 'docker top' do and when would you use it?
docker top lists the processes running inside a specific container. It shows you what's actually executing within that container at any given time. For example, running 'docker top mongodb' reveals the MongoDB daemon process (mongod) running inside the container.
What happens when I run 'docker stop' on a container?
docker stop halts the process running inside the container. The container itself remains on your system in a stopped state (not deleted). You can restart it anytime with 'docker start', resuming the process—similar to how suspending a system process works.