如何将主机设备挂载到Docker容器中? [英] How to mount a device of host to host in a Docker container?

查看:621
本文介绍了如何将主机设备挂载到Docker容器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有块设备 / dev / sdb 的Linux主机,我想将该设备安装到主机的 / mnt / sdb

I have a Linux host with a block device /dev/sdb , and I want to mount the device to host's /mnt/sdb.

我的特殊需要是在容器中执行此操作,而不是在主机本身中执行此操作,并且也无需将设备安装到容器中(例如 -v )。

My special need is that do this in a container but not in the host itself, and need not to mount the device into container also (for example -v).

例如(不一定能正常工作):

For example (does not work certainly):

$ docker run some-image mount /dev/sdb /mnt/sdb

还是绝对不可能?

推荐答案

Docker支持在设备中添加/传递设备容器:

Docker supports adding/passing through devices to a container:

docker run --device=/dev/sdb

https://docs.docker.com/engine/reference/commandline/run/#add-host-device-to-container-device

这篇关于如何将主机设备挂载到Docker容器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆