- 1 year ago
Docker in window map between windows folder and linux folder
When running Docker on Windows, you can map a Windows folder to a Linux container by specifying the volume mapping in your Docker run command or Docker Compose file.
Here's an example of how you can map a Windows folder to a Linux folder using the -v
flag in Docker run:
bashdocker run -v /path/on/linux:/path/on/container image_name
In the above command, /path/on/linux
represents the absolute path of the directory on the Linux container, and /path/on/container
represents the absolute path of the directory on the Windows host.
For example, if you want to map the C:\data
folder on your Windows machine to the /app/data
folder in the Linux container, you can use the following command:
javascriptdocker run -v C:\data:/app/data image_name
This will make the contents of the C:\data
folder available inside the /app/data
folder in the Linux container.
Note that Docker automatically handles the file system translation between Windows and Linux, so you don't need to worry about the different file system conventions.
If you are using Docker Compose, you can define the volume mapping in your docker-compose.yml
file as follows:
yamlservices:
myservice:
volumes:
- C:\data:/app/data
With this configuration, the C:\data
folder on the Windows host will be mounted to the /app/data
folder in the container.
Remember to adjust the paths and image names according to your specific setup.
By mapping the Windows folder to a Linux folder in your Docker setup, you can seamlessly share data between the Windows host and the Linux container.