Skip to content

Instantly share code, notes, and snippets.

View arogozhnikov's full-sized avatar

Alex Rogozhnikov arogozhnikov

View GitHub Profile
@arogozhnikov
arogozhnikov / docker-run-user.sh
Created January 28, 2018 17:56 — forked from marten-cz/docker-run-user.sh
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