Skip to content

Instantly share code, notes, and snippets.

@arogozhnikov
Forked from marten-cz/docker-run-user.sh
Created January 28, 2018 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arogozhnikov/003f1d77ad151a15b6e626416e291349 to your computer and use it in GitHub Desktop.
Save arogozhnikov/003f1d77ad151a15b6e626416e291349 to your computer and use it in GitHub Desktop.
Run docker with current user
# Run command with the same user ID as current user
# -v $(pwd):/tmp/mount - mount current directory to /tmp/mount/
# --env HOME="/tmp/" - some commands may need to be able to write to your home, se it to temporary folder
docker run -ti --rm -v $(pwd):/tmp/mount —user=$(id -u) --env HOME="/tmp/" debian:jessie
# Mount current users and group and be able to use them
# mount /etc/group and /etc/passwd read only
# set user from $USER
docker run -ti --rm -v $(pwd):/tmp/mount -w /tmp/hx -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro —user=$USER debian:jessie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment