This is the data volume mount command
docker run -it -v /host absolute path directory: /container directory image name
In Linux, we can directly use this command to mount, so how to mount the directory under our c drive and d drive to the container in windows, in fact, just add /mnt in front of the path, let’s demonstrate it below
First pull an ubuntu image
docker pull ubuntu
Let's take a look at Linux for comparison
This is the command used to mount data volumes under Linux systems in general
docker run -it --privileged=true -v /tmp/host_data:/tmp/docker_data ubuntu
windows
Open cmd and enter wsl first
Mount the win_host in the d disk of the window to the container
docker run -it --privileged=true -v /mnt/d/win_host:/tmp/docker_data ubuntu
Enter the tmp/docke directory in the container to create a text
Create a def text in win_host
It can be seen that the files in the two directories have been updated synchronously at this time, and the container volume has been mounted successfully.
Common commands
Foreground interactive start
docker run -it ubuntu /bin/bash
background daemon start
docker run -d ubuntu
To exit the container, enter exit or ctrl+P+Q
Enter the container terminal again
docker exec -it 8340b2231709 /bin/bash