steveny2k / docker-predictionio

Docker container for PredictionIO-based machine learning services
73 stars 57 forks source link

/PredictionIO-0.10.0-incubating/bin/pio-start-all: line 74: sudo: command not found #3

Closed ebuildy closed 6 years ago

ebuildy commented 7 years ago

Just run container as you said in REAME.md and got:

root@cdd207edcc50:/# pio-start-all
Starting Elasticsearch...
Starting HBase...
starting master, logging to /PredictionIO-0.10.0-incubating/vendors/hbase-1.0.0/bin/../logs/hbase--master-cdd207edcc50.out
/PredictionIO-0.10.0-incubating/bin/pio-start-all: line 74: sudo: command not found
nloui commented 7 years ago

Having the same issue

timsweb commented 7 years ago

Here too. Really hacky, but I installed postgres through apt and removed sudo from the start and stop scrips and that seemed to get me going.

steveny2k commented 6 years ago

Could you try? $ docker run -it -p 8000:8000 steveny/predictionio:0.12.0 /bin/bash then $ pio-start-all thanks for feedback.

poswald commented 6 years ago

I also get this error but not with the 0.12.0 version command

steveny2k commented 6 years ago

@ebuildy @nloui @timsweb @poswald The line pio-start-all: line 74 is to start postgres. The Dockerfile does not install postgres, so even after installing sudo there will be error about postgres. So you can ignore that error.

steveny2k commented 6 years ago

I am closing this issue. You can re-open if needed

anandumdas commented 6 years ago

The error happens because the binary you are trying to call from command line is only part of the current user's PATH variable, but not a part of root user's PATH.

You can verify this by locating the path of the binary you are trying to access. In my case I was trying to call "bettercap-ng". So I ran,

$ which bettercap-ng

output: /home/user/work/bin/bettercap

I checked whether this location is part of my root user's PATH.

$ sudo env | grep ^PATH

output: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

So sudo cannot find the binary that I am trying to call from commandline. Hence returns the error command not found.

You can direct sudo to use the current user's PATH when calling a binary like below.

$ sudo -E env "PATH=$PATH" [command] [arguments]

In fact, one can make an alias out of it:

$ alias mysudo='sudo -E env "PATH=$PATH"'

It's also possible to name the alias itself sudo, replacing the original sudo.

Please refer to this video for step by step solution

steveny2k commented 6 years ago

@anandumdas thanks a lot for your detailed analysis. Could you create a pull-request so that I can merge your improvement to the code to the branch? thanks a lot.