Skip to content

Commit

Permalink
Make get.docker.io install directions slightly better by telling user…
Browse files Browse the repository at this point in the history
… exactly how to add themselves to the "docker" group

As a bonus, if the user has run this script the way we recommend (ie, without "sudo" or "su", run as their user), we can actually give them the exact command they'll need with their correct username substituted appropriately.

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
  • Loading branch information
tianon committed Jan 29, 2014
1 parent c82a2d1 commit 6cfe778
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion hack/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ if command_exists docker || command_exists lxc-docker; then
( set -x; sleep 20 )
fi

user="$(id -un 2>/dev/null || true)"

sh_c='sh -c'
if [ "$(whoami 2>/dev/null || true)" != 'root' ]; then
if [ "$user" != 'root' ]; then
if command_exists sudo; then
sh_c='sudo sh -c'
elif command_exists su; then
Expand Down Expand Up @@ -124,6 +126,16 @@ case "$lsb_dist" in
$sh_c 'docker run busybox echo "Docker has been successfully installed!"'
) || true
fi
your_user=your-user
[ "$user" != 'root' ] && your_user="$user"
echo
echo 'If you would like to use Docker as a non-root user, you should now consider'
echo 'adding your user to the "docker" group with something like:'
echo
echo ' sudo usermod -aG docker' $your_user
echo
echo 'Remember that you will have to log out and back in for this to take effect!'
echo
exit 0
;;

Expand Down

0 comments on commit 6cfe778

Please sign in to comment.