Skip to content

Instantly share code, notes, and snippets.

@marten-cz
Created April 8, 2017 15:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marten-cz/77b48b15928eb6f10c901073ff3e3425 to your computer and use it in GitHub Desktop.
Save marten-cz/77b48b15928eb6f10c901073ff3e3425 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