docker容器怎么挂载硬盘

要将硬盘挂载到Docker容器中,可以使用-v参数或--mount参数,具体步骤如下:

创建一个目录来挂载硬盘到容器中:

mkdir /path/to/host/dir

使用-v参数挂载硬盘到容器中:

docker run -v /path/to/host/dir:/path/in/container image_name

这样就将宿主机上的/path/to/host/dir目录挂载到容器中的/path/in/container目录中。

使用--mount参数挂载硬盘到容器中:

docker run --mount type=bind,source=/path/to/host/dir,target=/path/in/container image_name

同样将宿主机上的/path/to/host/dir目录挂载到容器中的/path/in/container目录中。

注意:在使用-v参数挂载硬盘时,还可以添加ro参数来将硬盘以只读模式挂载到容器中,例如:

docker run -v /path/to/host/dir:/path/in/container:ro image_name
阅读剩余
THE END