self-hosted icon indicating copy to clipboard operation
self-hosted copied to clipboard

Doesn't detect docker even though its installed and in PATH

Open coolaj86 opened this issue 1 year ago • 2 comments

Update: Possible Solutions

Rather than instructing the user to use sudo prematurely, the install script could detect whether or not the current user has permissions to the docker group, or ask the user if they really want to sudo:

if ! groups | grep -q docker; then
    echo "$(id -u -n) is not a member of the group 'docker'"
    echo "Possible solutions:"
    echo "    sudo useradd '$(id -u -n)' 'docker' ; bash ./install.sh"
    echo "Or"
    echo "    sudo bash ./install.sh"
fi

Or

g_sudo=''
if ! groups | grep -q docker; then
    echo "$(id -u -n) is not a member of the group 'docker'"
    printf "Run using 'sudo'? [y/N] "
    read g_use_sudo
    if test "$g_use_sudo" = "y" || test "$g_use_sudo" = "yes"; then
        g_sudo='sudo'
    fi
fi
$g_sudo docker ...

In either case, if sudo is selectively used only for things that need sudo, it is less likely to cause permission or environment-related issues.

Self-Hosted Version

24.4.2

CPU Architecture

x86_64

Docker Version

25.0.5

Docker Compose Version

2.26.1

Steps to Reproduce

command -v docker
/home/app/.local/opt/docker/bin/docker
VERSION="24.4.2"
git clone https://github.com/getsentry/self-hosted.git
cd ./self-hosted/
git checkout ${VERSION}
sudo ./install.sh
HEAD is now at 935a683 release: 24.4.2
� Parsing command line ...

� Detecting Docker platform
FAIL: Could not find a `docker` binary on this system. Are you sure it's installed?

Expected Result

Should detect docker from the current PATH.

Actual Result

Used something other than PATH.

Event ID

No response

coolaj86 avatar May 06 '24 17:05 coolaj86

What I actually had done was this:

sentry-install.sh:

# Assuming current latest version is 24.1.0
# Current actual version can be acquired from the Releases page on GitHub
VERSION="24.4.2"
git clone https://github.com/getsentry/self-hosted.git
(
        cd self-hosted || exit 1
        git checkout "${VERSION}"
        sudo ./install.sh
)
sh ./sentry-install.sh

By happenstance while debugging I manually went into ./self-hosted/ and ran bash ./install.sh (not sudo) and now it's gotten much further:

Relay credentials written to relay/credentials.json.

� Generating secret key ...
Secret key written to sentry/config.yml

� Fetching and updating Docker images ...

and still going

So this issue is probably related to trying to using sudo where it isn't needed.

Possible Solution

This should probably instead checking that the current user has permissions to docker rather than trying to elevate permissions prematurely:

if ! groups | grep -q docker; then
    echo "$(id -u -n) is not a member of the group 'docker'"
    echo "Possible solutions:"
    echo "    sudo useradd '$(id -u -n)' 'docker' ; bash ./install.sh"
    echo "Or"
    echo "    sudo bash ./install.sh"
fi

coolaj86 avatar May 06 '24 18:05 coolaj86

Good solution.

I think we'd welcome a PR to this effect if you'd be so inclined!

azaslavsky avatar May 07 '24 20:05 azaslavsky

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

getsantry[bot] avatar May 29 '24 07:05 getsantry[bot]