简体   繁体   中英

Mounting Windows drives to access from Docker

I am looking to use files on my Windows computer in a Docker container. This is explained here .

My question relates to how to get to the Docker settings dialogue.

I am using Docker Toolbox on Windows 10. When I right-click on the Docker icon from the task bar, I get three options:

  1. Docker Quick Start Terminal;
  2. Unpin from taskbar; and
  3. close the window.

I am not getting settings dialogue box. How can I see that option?

Docker toolbox would be using VirtualBox .
The answer you are referring to is likely to use Docker for Windows with Hyper-V : see " Install Docker for Windows "

Docker for Windows requires Microsoft Hyper-V to run. After Hyper-V is enabled, VirtualBox will no longer work, but any VirtualBox VM images will remain.
VirtualBox VMs created with docker-machine (including the default one typically created during Toolbox install) will no longer start. These VMs cannot be used side-by-side with Docker for Windows. However, you can still use docker-machine to manage remote VMs.

Install Docker for Windows:

  • Docker does not run natively on Windows.

  • If the OS is not Windows 10 pro, Docker is set up through Docker Toolbox.

  • Once the Docker is installed through Docker Toolbox, follow the steps below:

Step 1: Click on "Docker Quickstart Terminal" on Windows to launch. This launches a Docker machine - a virtual machine named "default" through Oracle VirtualBox .

Step 2: Open up a command prompt window on Windows. Since step 1 created the Docker machine, we can issue docker-machine commands from cmd. The command docker-machine ls will list the running virtual machine with its name (default). Note you can create as many virtual machines as you need from cmd using docker-machine create --driver drivername vmname command.

Step 3: Running the docker client The Docker clients run on a specific virtual machine. This means we need to tell the client where the Docker host is (Oracle VirtualBox - not the Windows laptop) and which virtual machine to target. The following helps to simplify to target the specific virtual machine.

C:\Users\B> docker-machine env --shell cmd default

SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=C:\Users\B\.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
SET COMPOSE_CONVERT_WINDOWS_PATHS=true
REM Run this command to configure your shell:
REM     @FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO @%i

If you just run the following on cmd:
@FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO @%i

All the above environment variables will be set up. We can then issue client (Docker) commands from cmd targeting the "default" Docker virtual machine.

Step 4: Now we want to make the Windows folder available to the Docker virtual machine named "default" so that that the container (or containers) running on that virtual machine can make use of data on this folder.

Go to the VirtualBox running on your laptop. Locate the virtual machine "default" and select the settings (this is what I was asking for in my original question) and share the Windows folder /c/Users .

[Note: This settings dialogue option is usually available by right clicking on the Docker icon from the system tray, if Docker has been installed directly on Windows (10 pro).]

Now issue the command from cmd:

docker run -it --name suorsa -v /c/Users:/datavol ImageName:latest

The folder /c/Users is now available for access as in /datavol for the containers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM