docker 可以写入光盘吗?

Can docker write to a cd?

可以docker写入CD吗?可以docker执行

cdrecord dev=/dev/sr0 -checkdrive

来自 Ubuntu 容器?

Docker好像可以使用parent的网络硬件,为什么不能使用parent的cdrom/DVD设备呢?

更新:

这个问题是关于编程的,因为我在 Ubuntu VM 上 运行 有一些 shell 脚本,我想知道迁移到 docker。对于最初没有指出这一点,我深表歉意:)

我想是的(还没有测试过),你可以在这个 docker run script:

中找到一个例子
docker run \
-t --rm \
--privileged \
-v $XSOCK:$XSOCK \
-v /etc/localtime:/etc/localtime:ro \
-v /dev/sr0:/dev/sr0 \
-v /dev/cdrom:/dev/cdrom \
-v $RIPS:/rips \
--name handbrake marvambass/handbrake &

如前所述 by Luca, the --privileged flag is required (docker run):

by default, most potentially dangerous kernel capabilities are dropped; including cap_sys_admin (which is required to mount filesystems). However, the --privileged flag will allow it to run.

The --privileged flag gives all capabilities to the container, and it also lifts all the limitations enforced by the device cgroup controller.
In other words, the container can then do almost everything that the host can do.
This flag exists to allow special use-cases, like running Docker within Docker.


Vincent Demeester mentions 一样,还有--device选项:

It is often necessary to directly expose devices to a container. The --device option enables that.
For example, a specific block storage device or loop device or audio device can be added to an otherwise unprivileged container (without the --privileged flag) and have the application directly access it.

By default, the container will be able to read, write and mknod these devices. This can be overridden using a third :rwm set of options to each --device flag

Note: --device cannot be safely used with ephemeral devices. Block devices that may be removed should not be added to untrusted containers with --device.

issue 10637, some devices can change their node names. See issue 8826

If you launch the Docker daemon with the lxc backend, you should be able to use --lxc-conf=lxc.cgroup.devices.allow = c 189:* rwm to allow your container to access all devices of that group, and then use a volume -v /dev/bus/usb/:/dev/bus/usb/ to access all USB devices.