You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker Machine复制主机全部文件系统,这是预期行为吗?

Is it expected that the host's filesystem is accessible in a Docker Machine created with VirtualBox?

Yes, this is expected behavior when using docker-machine with the VirtualBox driver—here's a breakdown of what's happening:

When you run docker-machine create -d virtualbox machine_name, the tool automatically sets up a shared folder between your local host and the VirtualBox VM. By default, it shares your local user home directory (e.g., /Users/your-name on macOS, /home/your-name on Linux, or C:\Users\your-name on Windows) to the exact same path inside the VM. This is intentional: it lets you use your local project files directly with Docker containers running in the VM, which aligns perfectly with how your docker-compose.yml uses relative-path volume mounts (like ./services/client:/usr/src/app).

It might seem like your entire host filesystem is present, but in reality, only your shared home directory is accessible. The rest of the VM’s filesystem is entirely separate from your host—you can confirm this by checking paths outside your home folder (like /root or /var in the VM) which won’t match your host’s files.

If you don’t want your full home directory shared, you can customize the mount when creating the machine with the --virtualbox-share-folder flag. For example, to share only your project directory instead:

docker-machine create -d virtualbox --virtualbox-share-folder "/path/to/your/project:/home/docker/my-project" machine_name

This restricts the shared content to just the directory you need, rather than your entire home folder.

内容的提问来源于stack exchange,提问作者Munsterberg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:39:41