Docker Community Forums

Share and learn in the Docker community.

Making removable media accessible from container

I need a way to make a thumb drive visible inside a container after the thumb drive is plugged in.

I’ve tried a couple of things. One is exposing the/dev hierarchy inside the container. Ran into a race condition where udev on the host and the container did different and incompatible things to the dev hierarchy when plugging in the thumb drive.

The next thing I tried was using a volume sharing the space between the container and the host OS. The volume configuration propagated changes between container and host filesystems. I had the idea that if I created mount point inside the shared host file system, it should, in theory the mount point should have propagated into the container but it didn’t.

A fragment from the docker-compose configuration file.

volumes:
     - /srv/test/data:/srv/test/data:consistent
     - type: bind
       source: /media/test/usb0
       target: /media/test/usb0

I tried a couple variations of this, with and without the usb0 directory and again the mount point change didn’t propagate into the container. I saw something about bind propagation that looked like it might do what I needed but I couldn’t find a way to get docker-compose to accept it.

Any suggestions on what I’m missing?