You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派Raspbian GNU/Linux 11(bullseye)环境下Docker安装失败问题求助

Fixing "Held Broken Packages" When Installing Docker on Raspbian 11 (Bullseye)

Let’s work through this issue step by step—broken packages are a common snag on Raspbian, usually tied to leftover dependencies, partial uninstalls, or mismatched architecture settings. Here’s how to resolve it:

Step 1: Resolve Held/Broken Packages First

The core error E: Unable to correct problems, you have held broken packages tells us we need to fix system dependencies before proceeding:

  • List any packages marked as "held" (locked from updates or installs):
    apt-mark showhold
    
  • If any packages appear, unlock them with:
    sudo apt-mark unhold <package-name>
    
  • Run the dependency repair tool to fix broken packages:
    sudo apt-get -f install
    

Wait for this command to finish without errors before moving on.

Step 2: Clean Up Hidden Docker Residues

Even though dpkg -l | grep docker shows no packages, leftover configuration files or APT sources might be interfering:

  • Delete Docker’s APT source list and GPG key:
    sudo rm /etc/apt/sources.list.d/docker.list
    sudo rm /etc/apt/keyrings/docker.gpg
    
  • Clear cached packages and refresh the APT index:
    sudo apt-get clean
    sudo apt-get update
    

Step 3: Verify Your Pi’s Architecture & Install Docker Manually

The official get-docker.sh script might use the wrong architecture for your Pi. Let’s confirm your system’s architecture first:

dpkg --print-architecture

Then install Docker with the correct source line for your setup:

  1. Re-add Docker’s GPG key:
    curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    
  2. Add the matching APT source:
    # For arm64 architecture
    echo "deb [arch=arm64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/raspbian bullseye stable" | sudo tee /etc/apt/sources.list.d/docker.list
    # For armhf architecture (use this if your earlier output was armhf)
    echo "deb [arch=armhf signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/raspbian bullseye stable" | sudo tee /etc/apt/sources.list.d/docker.list
    
  3. Update and install Docker:
    sudo apt-get update
    sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    

Step 4: Verify Installation

Once installed, confirm Docker works:

sudo docker --version

If you want to run Docker without sudo, add your user to the docker group (log out and back in after this command for changes to take effect):

sudo usermod -aG docker $USER

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 20:13:15