Created
March 18, 2016 23:44
-
-
Save danhigham/67939ced008b96e7aa43 to your computer and use it in GitHub Desktop.
Function to allow access to host devices from a container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function permit_device_control() { | |
| local devices_mount_info=$(cat /proc/self/cgroup | grep devices) | |
| local devices_subsytems=$(echo $devices_mount_info | cut -d: -f2) | |
| local devices_subdir=$(echo $devices_mount_info | cut -d: -f3) | |
| if [ ! -e /tmp/devices-cgroup ]; then | |
| mkdir /tmp/devices-cgroup | |
| mount -t cgroup -o $devices_subsytems none /tmp/devices-cgroup | |
| fi | |
| echo a > /tmp/devices-cgroup${devices_subdir}/devices.allow || true | |
| umount /tmp/devices-cgroup || true | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment