如何将通过apt安装的docker-compose升级至最新或1.9.0+版本?
Hey there! Let's walk through upgrading your Docker Compose from v1.8.0 to at least v1.9.0 (or the latest stable version) properly. Since you installed the old version via apt, we'll start by removing that package cleanly, then install the official up-to-date build as Docker recommends.
1. Uninstall the Old APT Version
First, we need to remove the v1.8.0 package you installed via apt—this ensures no conflicts with the new version:
# Remove the core package sudo apt-get remove docker-compose # Optional but recommended: Purge residual configuration files sudo apt-get purge docker-compose # Clean up unused dependencies sudo apt-get autoremove
2. Install the Latest Official Version
Docker's official method uses curl to pull the pre-built binary tailored to your system. This command automatically detects your OS and architecture to grab the correct build:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Pro tip: If you specifically want v1.9.0 instead of the latest stable release, replace latest in the URL with v1.9.0.
3. Set Executable Permissions
The downloaded binary won't be runnable until we grant it execute permissions:
sudo chmod +x /usr/local/bin/docker-compose
4. Verify the Upgrade
Check the installed version to confirm everything worked as expected:
docker-compose --version
You should see a version number that's at least v1.9.0 (or the latest stable release).
Optional: Fix "Command Not Found" Errors
If your system can't locate docker-compose after installation, create a symlink to add it to your system's default PATH:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
内容的提问来源于stack exchange,提问作者Sam_2207

