Moby: Document mounting a device such as a USB to a running container

Created on 1 Mar 2016  路  3Comments  路  Source: moby/moby

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/

aredocs exintermediate

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 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.

All 3 comments

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!

Was this page helpful?
0 / 5 - 0 ratings