Skip to content

Instantly share code, notes, and snippets.

@ederst
Forked from nitrobin/docker-run-as-current-user.sh
Last active February 28, 2018 14:38
Show Gist options
  • Save ederst/f43b533b1a93ef5c82e5b6fc0bb406fd to your computer and use it in GitHub Desktop.
Save ederst/f43b533b1a93ef5c82e5b6fc0bb406fd to your computer and use it in GitHub Desktop.
# http://wiki.ros.org/docker/Tutorials/GUI
# mount /etc/group and /etc/passwd read only
# set user from $USER
docker run -ti --rm -v $(pwd):/tmp/hx -w /tmp/hx -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro —user=$USER debian:jessie
#With newer versions of docker volumes don't get mounted until after the user is assumed. However, if you use -u=$UID instead of --user=$USER it will work.
#If you want to match the group id too you can do -u=$UID:$(id -g $USER)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment