sudo: docker-compose: command not found

前端 未结 7 2163
梦谈多话
梦谈多话 2020-12-25 09:56

I am trying to run docker-compose using sudo.

I have both docker and docker-compose installed on Ubuntu 16.01.

Due to an error while trying to download compo

相关标签:
7条回答
  • 2020-12-25 09:57

    If you have tried installing via the official docker-compose page, where you need to download the binary using curl:

    curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
    

    Then do not forget to add executable flag to the binary:

    chmod +x /usr/local/bin/docker-compose
    

    If docker-compose is installed using python-pip

    sudo apt-get -y install python-pip
    sudo pip install docker-compose
    

    try using pip show --files docker-compose to see where it is installed.

    If docker-compose is installed in user path, then try:

    sudo "PATH=$PATH" docker-compose
    

    As I see from your updated post, docker-compose is installed in user path /home/user/.local/bin and if this path is not in your local path $PATH, then try:

    sudo "PATH=$PATH:/home/user/.local/bin" docker-compose
    
    0 讨论(0)
  • 2020-12-25 09:59

    I have same issue , i solved issue :

    step-1 : download docker-compose using following command.

         1.  sudo su
    
         2. sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
    

    Step-2 : Run command

        chmod +x /usr/local/bin/docker-compose
    

    Step-3 : Check docker-compose version

         docker-compose --version
    
    0 讨论(0)
  • 2020-12-25 10:08

    Or, just add your binary path into the PATH. At the end of the bashrc:

    ... 
    export PATH=$PATH:/home/user/.local/bin/
    

    save the file and run:

    source .bashrc
    

    and the command will work.

    0 讨论(0)
  • 2020-12-25 10:15

    If docker-compose is installed for your user but not installed for root user and if you need to run it only once and forget about it afterwords perform the next actions:

    • Find out path to docker-compose:

        which docker-compose
      
    • Run the command specifying full path to docker-compose from the previous command, eg:

        sudo /home/your-user/your-path-to-compose/docker-compose up
      
    0 讨论(0)
  • 2020-12-25 10:17

    The output of dpkg -s ... demonstrates that docker-compose is not installed from a package. Without more information from you there are at least two possibilities:

    1. docker-compose simply isn't installed at all, and you need to install it.

      The solution here is simple: install docker-compose.

    2. docker-compose is installed in your $HOME directory (or other location not on root's $PATH).

      There are several solution in this case. The easiest is probably to replace:

      sudo docker-compose ...
      

      With:

      sudo `which docker-compose` ...
      

      This will call sudo with the full path to docker-compose.

      You could alternatively install docker-compose into a system-wide directory, such as /usr/local/bin.

    0 讨论(0)
  • 2020-12-25 10:18

    On Ubuntu 16.04

    Here's how I fixed this issue: Refer Docker Compose documentation

    1. sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

    2. sudo chmod +x /usr/local/bin/docker-compose

    After you do the curl command , it'll put docker-compose into the

    /usr/local/bin

    which is not on the PATH. To fix it, create a symbolic link:

    1. sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

    And now if you do: docker-compose --version

    You'll see that docker-compose is now on the PATH

    0 讨论(0)
提交回复
热议问题