How to upgrade docker-compose to latest version

后端 未结 12 2211
遇见更好的自我
遇见更好的自我 2020-12-23 09:05

I have installed docker-compose using the command

sudo apt install docker-compose

It installed docker-compose version 1.8.0 and build unknown

12条回答
  •  自闭症患者
    2020-12-23 09:38

    First, remove the old version:

    If installed via apt-get

    sudo apt-get remove docker-compose
    

    If installed via curl

    sudo rm /usr/local/bin/docker-compose
    

    If installed via pip

    pip uninstall docker-compose
    

    Then find the newest version on the release page at GitHub or by curling the API if you have jq installed (thanks to dragon788 and frbl for this improvement):

    VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
    

    Finally, download to your favorite $PATH-accessible location and set permissions:

    DESTINATION=/usr/local/bin/docker-compose
    sudo curl -L https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m) -o $DESTINATION
    sudo chmod 755 $DESTINATION
    

提交回复
热议问题