We can provide access to host devices inside containers. We use the --device argument with docker container create or docker container run for this. We will be able to use hardware devices connected directly to a host, such as serial controllers, block storage, or audio devices.
By default, devices will have read and write permissions. To be able to manipulate special devices, the mknod permission is also added by default. We can override these default settings using r, w, and m in the command line as modifiers of the --device option.
As an example, we can mount our lvm mapped block device to a defined directory; notice that the mounting capability must be added. In this example, we added SYS_ADMIN capabilities:
$ docker run -ti --cap-add SYS_ADMIN --device /dev/mapper/centos-root:/dev/sdx centos
[root@5ccb0ef8ce84 /]# mkdir /data
[root@5ccb0ef8ce84 /]# mount /dev/sdx /data
[root@5ccb0ef8ce84 /]# cd /data
[root@5ccb0ef8ce84 data]# ls
bin boot dev etc home lib lib64...