Skip to content

Instantly share code, notes, and snippets.

@porst17
Last active March 8, 2016 15:08
Show Gist options
  • Save porst17/24b17cf2e24edc26233c to your computer and use it in GitHub Desktop.
Save porst17/24b17cf2e24edc26233c to your computer and use it in GitHub Desktop.
Some docker commands, I would like to remember

Use the current user and his group(s) inside the container:

docker run
  -ti
  --rm
  -u `id -u`
  -v /etc/group:/etc/group
  -v /etc/passwd:/etc/passwd
  alpine
  /bin/sh

If you want to set a specific group my_primary_group as primary group:

docker run
  -ti
  --rm
  -u `id -u`:my_primary_group
  --group-add `id -G | sed "s/ / --group-add /g"`
  -v /etc/group:/etc/group
  -v /etc/passwd:/etc/passwd
  alpine
  /bin/sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment