- Hands-On Kubernetes on Windows
- Piotr Tylenda
- 280字
- 2021-06-24 16:54:01
Mounting a local container host directory using bind mounts
Bind mounts are the simplest form of persistent storage that is shared between the container and the host machine. In this way, you can mount any existing directory from the host filesystem in the container. It is also possible to "overwrite" an existing directory in the container with host directory contents, which may be useful in some scenarios. In general, volumes are the recommended storage solution, but there are a few cases where bind mounts can be useful:
- Sharing configuration between the host and the container. A common use case may be DNS configuration or the hosts file.
- In development scenarios, sharing build artifacts that were created on the host so that they can be consumed inside the container.
- On Windows, mounting SMB file shares as directories in the container.
Creating a bind mount for a container requires the docker run command to be specified with an additional parameter, type=bind, for the --mount flag. In this example, we will mount the host's C:\Users directory as C:\HostUsers in the container:
docker run -it --rm `
--isolation=process `
--mount type=bind,source=C:\Users,target=C:\HostUsers `
mcr.microsoft.com/powershell:windowsservercore-1903
You can verify that any changes performed to C:\HostUsers will also be visible on the host machine in C:\Users.
In the next section, we are going to learn how to leverage bind mounts in order to use remote or cloud storage in Windows containers.
- Visual C++程序設計學習筆記
- JavaScript+jQuery開發實戰
- 區塊鏈:以太坊DApp開發實戰
- 微信小程序入門指南
- OpenCV 4計算機視覺項目實戰(原書第2版)
- Mastering openFrameworks:Creative Coding Demystified
- Python機器學習:預測分析核心算法
- Machine Learning in Java
- C# and .NET Core Test Driven Development
- C語言程序設計與應用(第2版)
- MATLAB GUI純代碼編寫從入門到實戰
- CodeIgniter Web Application Blueprints
- Mastering jQuery Mobile
- 少兒編程輕松學(全2冊)
- Android應用開發攻略