树莓派Raspbian GNU/Linux 11(bullseye)环境下Docker安装失败问题求助
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:
- Re-add Docker’s GPG key:
curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg - 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 - 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

