Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to mount a local directory in docker toolbox

Shulou Source: shulou.com Published: 2022-05-31 20:15:26 09月22日 Update

This article mainly introduces how to mount the local directory in docker toolbox, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Preparation condition

Create a new vm_share folder in the root directory of the e disk, and create several new test files under that file, such as:

Mount directory form one

After starting Docker quickstart Terminal, go to the interface shown in the figure. If you execute the mount command at this time, you can only mount the directory of the current user of disk c. Mounting other disks will not take effect and will not report an error. For example, execute the following command

Docker run-it-- name busybox1-v / e/vm_share:/opt busybox sh

After entering the container, look in the / opt directory and you can see that the files are not shared.

If you want to mount to another drive letter in this form, you can establish a soft connection to the shared directory we specified by establishing a soft connection under the current user's directory of disk c.

Mklink "c:/Users/ user name / vm_share"e:/vm_share"

And then through the command

Docker run-it-- name busybox1-v c:/Users/ user name / vm_share:/opt busybox sh

At this point, you can access the files in the specified directory

Mode two

Open Oracle VM VirtualBox in the start menu bar

Select shared folder, select add, select the folder we need to share, and check automatic mount and fixed allocation. After saving, use the command in cmd or Docker quickstart Terminal.

Docker-machine restart

Restart the docker machine, and after the restart is complete, use the command

Docker-machine ssh default

Go to the docker machine and the shared directory is in the / directory. Then execute the mount command at this time.

Docker run-it-- name busybox5-v / vm_share:/opt busybox sh

You can also see the files under the shared folder at this time.

Thank you for reading this article carefully. I hope the article "how to mount a local directory in docker toolbox" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Directories files commands folders users articles selections forms machines user names values interests at the same time containers ways more friends conditions interfaces knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Microsoft Shulou Technology Redmi