Does Stopping a Docker Container Equate to Shutting Down a VirtualBox VM?

To clarify, stopping a running Docker container is not the same as pausing it. Stopping a container terminates the processes inside the container and releases associated resources (like CPU and memory), but the container’s filesystem and state remain intact, similar to how VirtualBox retains hard disk data after shutting down a VM. The container’s data stays unless explicitly deleted (using rm).

The Difference Between Stop and Pause:

  • Stop: Completely terminates all processes inside the container, similar to turning off the power. When the container is restarted, it begins from its configured entry process.
  • Pause: Freezes all processes inside the container, keeping their state intact, but without releasing resources. A paused container can be resumed, much like the Suspend feature in VirtualBox.

停止(注意不是暂停)运行docker容器是不是相当于VirtualBox的虚拟机关机?

具体来说,停止运行中的 Docker 容器会终止容器内部的进程,释放相关的资源(如 CPU 和内存),但容器的文件系统和状态会被保留,就像 VirtualBox 虚拟机关机后硬盘数据依然保存一样,除非进行删除(rm)操作。

停止和暂停的区别在于:

  • 停止(stop):完全终止容器内的进程,相当于电源关闭,容器在下次启动后会重新开始其配置的入口进程。
  • 暂停(pause):冻结容器内的所有进程,进程状态保持,但并不释放资源,暂停的容器可以恢复继续运行,类似于 VirtualBox 的暂停(Suspend)功能。