Skip to content

Instantly share code, notes, and snippets.

@igor-egorov
Created March 23, 2021 18:54
Show Gist options
  • Save igor-egorov/02ce85ff5eb52bce261f155afb63b92e to your computer and use it in GitHub Desktop.
Save igor-egorov/02ce85ff5eb52bce261f155afb63b92e to your computer and use it in GitHub Desktop.
# runs on host mac
echo $UID # prints your id
whoami # prints your username
docker pull ubuntu:18.04
cd to/your/cpp/projects/dir
docker run -it --name u18 -v "$PWD":/cpp:delegated --cap-add=SYS_PTRACE ubuntu:18.04
# get into container as root
docker exec -u 0 -it u18 bash
# inside docker as root
adduser --disabled-password --gecos "" -u <your uid from line 2> <your username from line 3>
# get into docker as your user
docker exec -u $(whoami) -it u18 bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment