$ sudo systemctl start docker
Failed to start docker.service: Unit docker.service not found.

The error indicates that the Docker service is not installed or recognized on your system. Here’s how to troubleshoot and resolve this issue on your Raspberry Pi:


1. Check if Docker is installed

Run the following command to check if Docker is installed:

docker --version

If it returns a version, Docker is installed but the service might be misconfigured. If it outputs command not found, Docker is not installed.


2. Install Docker

If Docker is not installed, install it using the official method for Raspberry Pi (Debian-based systems):

  1. Update the system packages:

    sudo apt update && sudo apt upgrade -y
    
  2. Install Docker:

    Run this command to install Docker from the official convenience script:

    curl -fsSL https://get.docker.com -o get-docker.sh
    sudo sh get-docker.sh
    

    This script detects your system architecture and installs the appropriate version of Docker.

  3. Verify installation:

    Check Docker’s version after installation:

    docker --version
    

3. Enable and Start the Docker Service

After installation, start and enable the Docker service:

sudo systemctl start docker
sudo systemctl enable docker

4. Add Your User to the Docker Group

To run Docker commands without sudo:

sudo usermod -aG docker $USER

Log out and log back in to apply the group changes, or use:

newgrp docker

5. Test Docker

Run a test container to ensure Docker is working:

docker run hello-world

If you see the “Hello from Docker!” message, your setup is successful.


6. Still Facing Issues?

If the service is still not found, it could be due to:

  1. Package Manager Issues: Ensure apt repositories are properly configured for your Raspberry Pi.
  2. Architecture Conflicts: Confirm your Raspberry Pi’s architecture (armhf vs arm64) is compatible with the Docker package.
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐