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)功能。

Fix for Unable to Create Symlinks in Shared Folders Between VirtualBox Linux VM and Windows Host

Software Setup:

  • VirtualBox VM: Ubuntu 22
  • Host: Windows 10

When attempting to create symbolic links in a shared folder within an Ubuntu 22 VirtualBox VM, you may encounter several errors:

1.Error during npm install esbuild:

    Error: EPERM: operation not permitted, symlink '../esbuild/bin/esbuild' -> '/var/www/reverb.test/node_modules/.bin/esbuild'

    2.Error when creating symlinks in PHP:

    symlink(): Operation not permitted

    3.Error when running the ln command:

    ln: failed to create symbolic link 'xxx.so.0': Read-only file system

    4.Error when running the cp command:

    cannot create symbolic link `xxxx': Read-only file system

    5.Another error during cp:

    cannot create symbolic link `xxxx': Protocol error

    These issues occur because VirtualBox restricts the creation of symbolic links in shared folders for security reasons. To allow symbolic link creation, you’ll need to enable the option VBoxInternal2/SharedFoldersEnableSymlinksCreate/<share_folder_name>. For Vagrant users, this option is automatically configured when running vagrant up. For VirtualBox users, you can manually enable this setting using the VBoxManage.exe tool, which is located in the same directory as the VirtualBox GUI on Windows.

    Step-by-Step Guide:

    1.Close VirtualBox.

    2.Open a command prompt with administrator privileges and navigate to the VirtualBox installation directory (e.g., cd C:\Programs\Oracle\VirtualBox). Then, execute the following command:

    VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

    1) Replace YOURVMNAME with the name of your Ubuntu VM.

    2) Replace YOURSHAREFOLDERNAME with the name of the shared folder, which corresponds to the “Shared Folder Name” you set in VirtualBox, not the actual folder path or its name.

    Example:

    VBoxManage setextradata Ubuntu22 VBoxInternal2/SharedFoldersEnableSymlinksCreate/share 1

    3 Run VirtualBox as an administrator to apply the changes.

    References:

    VirtualBox Linux虚拟机与Windows宿主机的共享文件夹里面无法创建符号链接的解决方法

    我的软件环境:

    VirtualBox虚拟机:Ubuntu 22

    宿主机:Windows 10

    在Ubuntu 22虚拟机的共享文件夹中创建符号链接时,可能的报错有以下几种:

    第一种,在运行npm install esbuild时报错:

    Error: EPERM: operation not permitted, symlink '../esbuild/bin/esbuild' -> '/var/www/reverb.test/node_modules/.bin/esbuild'

    第二种,执行PHP代码创建符号链接时报错:

    symlink(): Operation not permitted

    第三种,运行ln命令时报错:

    ln: failed to create symbolic link 'xxx.so.0': Read-only file system

    第四种,运行cp命令时报错:

    cannot create symbolic link `xxxx':Read-only file system

    第五种,运行cp命令时报错:

    cannot create symbolic link `xxxx': Protocol error

    ……

    原因是VirtualBox从安全角度出发,限制了软链接(符号链接)的创建。如果想正常使用符号链接,需要对虚拟机设置 VBoxInternal2/SharedFoldersEnableSymlinksCreate/<share_folder_name> 这个选项。这里顺带一提,对于 vagrant,这个选项只要你运行 vagrant up之后这个选项便会自动设置好。可以使用 VboxManage.exe设置这个选项 ,这个工具在 Windows 下是和 VirtualBox 图形界面程序在一个相同目录的。以下是详细步骤:

    1 关闭 VirtualBox。

    2 以管理员身份打开命令行窗口,cd到VirtualBox安装目录(例如cd C:\Programs\Oracle\VirtualBox),执行如下命令:

    VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

    其中:

    • YOURVMNAME填写ubuntu 虚拟机系统的名称
    • YOURSHAREFOLDERNAME填写共享文件夹的名称,注意这个共享文件夹名称是你在 VirtualBox 中设置共享时对应的“共享文件夹名称”一栏的内容,不是共享文件夹的路径或者文件夹的名称。

    例如:

    VBoxManage setextradata Ubuntu22 VBoxInternal2/SharedFoldersEnableSymlinksCreate/share 1

    3 以管理员身份运行VirtualBox

    参考

    https://blog.csdn.net/tekenuo/article/details/82386552

    https://tty.moe/blog/virtualbox-symlink-windows

    VirtualBox Linux虚拟机与Windows宿主机的共享文件夹里面无法创建符号链接的解决方法

    我的软件环境:

    VirtualBox虚拟机:Ubuntu 22

    宿主机:Windows 10

    在Ubuntu 22虚拟机中创建符号链接时,可能的报错有以下几种:

    第一种,在运行npm install esbuild时报错:

    Error: EPERM: operation not permitted, symlink '../esbuild/bin/esbuild' -> '/var/www/reverb.test/node_modules/.bin/esbuild'

    第二种,执行PHP代码创建符号链接时报错:

    symlink(): Operation not permitted

    第三种,运行ln命令时报错:

    ln: failed to create symbolic link 'xxx.so.0': Read-only file system

    第四种,运行cp命令时报错:

    cannot create symbolic link `xxxx':Read-only file system

    第五种,运行cp命令时报错:

    cannot create symbolic link `xxxx': Protocol error

    原因是VirtualBox从安全角度出发,限制了软链接(符号链接)的创建。如果想正常使用符号链接,需要对虚拟机设置 VBoxInternal2/SharedFoldersEnableSymlinksCreate/<share_folder_name> 这个 extradata。这里顺带一提,对于 vagrant,这个选项只要你运行 vagrant up之后这个选项便会自动设置好。可以使用 VboxManage设置这个 extradata ,这个工具在 Windows 下是和 VirtualBox 图形界面在一个相同目录的。以下是详细步骤:

    1 关闭 VirtualBox。

    2 以管理员身份打开命令行窗口,cd到VirtualBox安装目录(例如cd C:\Programs\Oracle\VirtualBox),执行如下命令:

    VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

    其中:

    YOURVMNAME填写ubuntu 虚拟机系统的名称

    YOURSHAREFOLDERNAME填写共享文件夹的名称,注意这个共享文件夹名称是你在 VirtualBox 中设置共享时对应的“共享文件夹名称”一栏的内容,不是共享文件夹的路径或者文件夹名称。

    3 以管理员身份运行VirtualBox

    参考

    https://blog.csdn.net/tekenuo/article/details/82386552

    https://tty.moe/blog/virtualbox-symlink-windows

    Kernel Panic – not syncing VFS Unable to mount root fs on unknown-block(0,0)问题的解决方法

    VirtualBox启动CentOS 7虚拟系统时,遇到Kernel Panic – not syncing: VFS: Unable to mount root fs on unknown-block(0,0)问题,无法启动系统。

    引起该问题的原因是缺少该内核的初始化文件。

    解决方法是从启动界面的GRUB菜单中选择另一个内核来启动系统。进入系统后运行sudo update-initramfs -u -k version为version生成初始化文件(将version替换为内核版本字符串,例如4.15.0-36-generic),然后运行sudo update-grub更新GRUB。

    参考

    https://askubuntu.com/questions/41930/kernel-panic-not-syncing-vfs-unable-to-mount-root-fs-on-unknown-block0-0