You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在Docker for Windows(Windows10+Hyper-V)上升级docker-compose?

How to Upgrade Docker Compose on Docker for Windows (Hyper-V)

Hey there! Let's get that docker-compose upgrade sorted out for you. The error you're hitting is because your current docker-compose version (1.20.1) uses an API version that's too old for your Docker setup—your compose file's version: '2' requires a newer API level. Here are the most reliable methods to upgrade, tailored to your Windows 10 + Hyper-V + Docker for Windows environment:

Docker for Windows (now called Docker Desktop) bundles docker-compose with it, so upgrading the entire app is the easiest way to get a compatible, up-to-date compose version:

  • Right-click the Docker icon in your system tray and select Settings
  • Go to the Software Updates tab
  • Click Check for updates—if an update is available, follow the prompts to install it
  • Once done, restart Docker Desktop, then open PowerShell/Command Prompt and run docker-compose --version to confirm the upgrade worked

Method 2: Manually Replace the Docker Compose Binary

If you don't want to upgrade the whole Docker Desktop app, you can manually swap out the compose executable:

  1. Open PowerShell as an administrator
  2. First, stop the Docker service to avoid conflicts:
    Stop-Service Docker
    
  3. Download the latest stable docker-compose binary for Windows from Docker's official releases page, then save it to C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe (replacing the existing file)
    Note: The path C:\Program Files\Docker\Docker\resources\bin\ is the default install location for Docker for Windows. If you installed Docker elsewhere, adjust this path accordingly.
  4. Start the Docker service back up:
    Start-Service Docker
    
  5. Verify the upgrade by running:
    docker-compose --version
    

Method 3: Use Chocolatey Package Manager (If You Have It Installed)

If you use Chocolatey to manage Windows software, upgrading is just a quick command:

  1. Open PowerShell as an administrator
  2. Run the upgrade command:
    choco upgrade docker-compose -y
    
  3. After the upgrade finishes, restart your terminal and run docker-compose --version to check the new version

Quick note: These methods are for the Hyper-V version of Docker for Windows. If you were using Docker Toolbox, the steps would be different—but since you specified Hyper-V, these should work perfectly.

Once you've upgraded, try running docker-compose up with your YAML file again, and that API version error should be gone. If you still run into issues, double-check your Docker engine version with docker version—sometimes upgrading Docker Desktop is necessary to get both the engine and compose in sync.

内容的提问来源于stack exchange,提问作者Rolf

火山引擎 最新活动