sudo: service: command not found

0

Hi,

I'm in the midst of working on the Step 4: Set Up a Client.

I'm able to install Docker and able to view the Docker Version but when comes to "sudo service docker start", it comes out the error --> sudo: service: command not found

The same goes to "go version".

Have tried different method but not working.

Please help, thanks.

已提問 1 年前檢視次數 4008 次
1 個回答
0

The "service" command may not be in the path.
So, try the following settings in "~/.bash_profile".

export PATH=$PATH:/sbin

After putting in the settings, execute the following command to reflect the settings.

source ~/.bash_profile

Or, try the "service" command, specifying the path.

sudo /sbin/service docker start
profile picture
專家
已回答 1 年前
  • Hi, thanks for the above guidance. Yes, I did update the ./bash_profile. Also, after updating it - I did type this --> source ~/.bash_profile as well before the following command below:

    sudo /sbin/service docker start sudo: /sbin/service: command not found
    and this one
    sudo service docker start sudo: service: command not found

  • What is the OS of the EC2 AMI you used?

  • Sorry, it may be "/usr/sbin" instead of "/sbin". Change all of the above steps to the path "/usr/sbin" and try again.

    export PATH=$PATH:/usr/sbin
    
    sudo /usr/sbin/service docker start
    
  • @Riku, to answer your question: What is the OS of the EC2 AMI you used? --> Amazon Linux Change all of the above steps to the path "/usr/sbin" and try again. --> Done.

    The Result:

    source ~/.bash_profile [cloudshell-user@ip-10-4-189-71 ~]$ sudo /usr/sbin/service docker start sudo: /usr/sbin/service: command not found [cloudshell-user@ip-10-4-189-71 ~]$ export PATH=$PATH:/usr/sbin [cloudshell-user@ip-10-4-189-71 ~]$ sudo /usr/sbin/service docker start sudo: /usr/sbin/service: command not found

  • It appears from your response that you are using CloudShell, but CloudShell cannot launch Docker. https://docs.aws.amazon.com/cloudshell/latest/userguide/vm-specs.html

    Currently, the AWS CloudShell compute environment doesn't support Docker containers.

    You are most likely not executing commands on EC2.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南