Skip to content

Instantly share code, notes, and snippets.

@unfor19
Created February 12, 2021 13:52
Show Gist options
  • Save unfor19/281d2adbc2ba89cb26a73d1f6d8a309e to your computer and use it in GitHub Desktop.
Save unfor19/281d2adbc2ba89cb26a73d1f6d8a309e to your computer and use it in GitHub Desktop.
mind-the-uid-gid-good-sh
# BAD
# Reminder - My machine's UID:GID is 1000:1000
# root UID:GID is 0:0
$ docker run --rm -it -v $PWD/:/code/ --user=root --workdir=/code/ --entrypoint=bash unfor19/frigga
root@987c5784a52e:/code$ cat /etc/passwd | grep "$(whoami)"
root:x:0:0:root:/root:/bin/bash
# UID:GID = 0:0
root@987c5784a52e:/code$ echo "root contents" > root-file.txt
root@987c5784a52e:/code$ ls -lh root-file.txt
# -rw-r--r-- 1 root root 14 Feb 12 14:03 root-file.txt
root@987c5784a52e:/code$ exit
# Local machine
$ ls -lh root-file.txt
# -rw-r--r-- 1 root root 14 Feb 12 14:04 root-file.txt
$ echo "more contents" >> root-file.txt
# bash: root-file.txt: Permission denied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment