Docker卷挂载疑问:Windows10下VirtualBox版Docker挂载点无法找到
Understanding Docker Volumes with VirtualBox-based Docker on Windows 10
Hey there! Let's clear up the confusion around your Docker volume setup—this is a super common gotcha when using the VirtualBox-backed Docker Toolbox on Windows, so you're not alone here.
Why you can't find the /mnt/sda1/var/lib/docker/volumes/my_vol/_data path on Windows
First, let's break down the architecture:
- When you use Docker Toolbox (the VirtualBox version), Docker isn't running directly on your Windows OS. Instead, it's running inside a lightweight Linux virtual machine (VM) managed by VirtualBox.
- The path shown in
docker volume inspect my_volis a file system path inside that Linux VM, not a path on your Windows host. That's why you can't locate it in Windows File Explorer—it doesn't exist there!
How to access your volume's content
You have two main options to interact with the files in your my_vol volume:
Access the volume directly from the Linux VM
- Open your Docker Quickstart Terminal (the one that launches with the whale icon).
- Run this command to SSH into the default Docker VM:
docker-machine ssh default - Once you're logged into the VM, you can navigate to the volume path and view its contents using standard Linux commands:
ls /mnt/sda1/var/lib/docker/volumes/my_vol/_data
Use a bind mount to link to a Windows directory (for direct local access)
If you want the volume's files to be visible and editable directly on your Windows machine, swap the named volume for a bind mount when starting your container. For example:docker run -d -p 221:22 -v /c/your/windows/path:/opt/my_vol --name my_dock_r1 my_dock- Note: In Docker Toolbox, Windows paths need to be formatted using forward slashes (e.g.,
/c/Users/YourName/Desktop/my_volume_files) instead of backslashes.
- Note: In Docker Toolbox, Windows paths need to be formatted using forward slashes (e.g.,
Did you misunderstand Docker volumes?
Nope! Your setup is totally correct:
- You defined a volume in your Dockerfile with
VOLUME /opt/my_vol - You successfully mounted the named volume
my_volto that container path when runningdocker run - The volume is working as expected—you can see it in
docker volume lsand access it inside the container. The only twist is the underlying VM storage, which is specific to the VirtualBox-based Docker setup.
内容的提问来源于stack exchange,提问作者TheLovelySausage
相关产品推荐
相关产品推荐

