Failed to start docker.service: Unit docker.service not found.
【代码】Failed to start docker.service: Unit docker.service not found.
$ 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):
-
Update the system packages:
sudo apt update && sudo apt upgrade -y
-
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.
-
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:
- Package Manager Issues: Ensure
apt
repositories are properly configured for your Raspberry Pi. - Architecture Conflicts: Confirm your Raspberry Pi’s architecture (
armhf
vsarm64
) is compatible with the Docker package.
更多推荐
所有评论(0)