Skip to content

Commit f3e1de4

Browse files
committed
Update check message to use sudo when appropriate
If bin/check is run as root (i.e. via sudo make install), and the user is unable to connect to docker (as root), the error message is confusing since it instructs them to ensure docker version succeeds (which it likely does). In fact, *sudo* docker version is the failing command that must succeed before sudo make install would. To address this confusion, we include sudo in the example command if the check script is being run as root (UID=0). Note: we're purposely ignoring the edge case where a user is running the check script as root but not via sudo (e.g. su root) and our example command incorrectly instructs them to try sudo docker version.
1 parent 01a5c47 commit f3e1de4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bin/check

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ docker version | grep -q "Server version\|Server:" || {
1010
if command -v boot2docker > /dev/null 2>&1; then
1111
echo "Please ensure \`boot2docker up\` succeeds and you've run \`eval \$(boot2docker shellinit)\` in this shell" >&2
1212
else
13-
echo "Please ensure \`docker version' succeeds and try again"
13+
if [ $UID -eq 0 ]; then
14+
echo "Please ensure \`sudo docker version' succeeds and try again" >&2
15+
else
16+
echo "Please ensure \`docker version' succeeds and try again" >&2
17+
fi
1418
fi
1519

1620
exit 1

0 commit comments

Comments
 (0)