mirror of
https://github.com/jessfraz/dockerfiles.git
synced 2024-11-27 04:16:45 +01:00
Add more devices, but only if they really exist
This commit is contained in:
parent
ae2529386d
commit
43c57f4f78
22
bashrc
22
bashrc
|
@ -13,13 +13,31 @@ command_not_found_handle () {
|
|||
return
|
||||
fi
|
||||
|
||||
# Add a bunch of (optional) devices
|
||||
# (Don't add them unconditionally: if they don't exist, it
|
||||
# would prevent the container from starting)
|
||||
DEVICES=
|
||||
for DEV in /dev/kvm /dev/ttyUSB* /dev/dri/* /dev/snd/*; do
|
||||
if [ -b "$DEV" -o -c "$DEV" ]; then
|
||||
DEVICES="$DEVICES --device $DEV:$DEV"
|
||||
fi
|
||||
done
|
||||
|
||||
# And a few (optional) files
|
||||
# (Here again, they don't always exist everywhere)
|
||||
VOLUMES=
|
||||
for VOL in /tmp/.X11-unix /run/user; do
|
||||
if [ -e "$VOL" ]; then
|
||||
VOLUMES="$VOLUMES --volume $VOL:$VOL"
|
||||
fi
|
||||
done
|
||||
|
||||
docker run -ti -u $(whoami) -w "$HOME" \
|
||||
$(env | cut -d= -f1 | awk '{print "-e", $1}') \
|
||||
-v /dev/snd:/dev/snd \
|
||||
$DEVICES $VOLUMES \
|
||||
-v /etc/passwd:/etc/passwd:ro \
|
||||
-v /etc/group:/etc/group:ro \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v /home:/home \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||
"$@"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user