I have a local Ubuntu 12.04 machine that I want to run Docker on with some application code. However the code needs to read data off of a USB drive when it is plugged in. Because the drive can be swapped, it seems like volume mounting it does not work when the new one is plugged in. Is there a way to configure Docker so that the usb detection is passed to Docker instead of just the host os?
Use docker run command and discussed here:
https://docs.docker.com/engine/reference/run/#volume-shared-filesystems
You can mount /dev using the -v flag. Any device that appears on /dev will show up in the container. If you do this, you'll likely also want to change the cgroup value to restrict the permissions to just the USB device.
Jerome in our company also wrote this blog on doing this:
https://jpetazzo.github.io/2015/01/13/docker-mount-dynamic-volumes/
While not a documentation change, something that might be nice is that if the container is launched with --privileged
, that /dev
be mounted as devtmpfs
instead of normal tmpfs
where the devices are manually populated by docker. With devtmpfs
, the kernel will automatically add/remove entries to /dev
as devices are added and removed.
@mstanleyjones do you know if this was updated in the documentation?
I doubt it!
Most helpful comment
While not a documentation change, something that might be nice is that if the container is launched with
--privileged
, that/dev
be mounted asdevtmpfs
instead of normaltmpfs
where the devices are manually populated by docker. Withdevtmpfs
, the kernel will automatically add/remove entries to/dev
as devices are added and removed.