Lesson 02: Docker on Pi5
2.1 Installing Docker on Raspberry Pi 5
Installing Docker on Raspberry Pi 5
There are two main methods to install Docker on your Raspberry Pi 5. Choose the one that best suits your needs.
Option 1: Using Docker's Convenience Script
This is the quickest and simplest method to install Docker:
- Download Docker's convenience script:
- Run the script to install Docker:
Option 2: Manual Installation
This method offers more control but involves additional steps. Follow these instructions to install Docker using its official APT repository:
- Update the package list and install prerequisites:
- Add Docker's official GPG key:
- Add Docker's repository to APT sources:
- Install Docker packages:
After completing these steps, Docker will be installed and ready to use on your Raspberry Pi 5.
Next Steps
After completing either installation method, Docker will be installed and ready to use on your Raspberry Pi 5. You can verify the installation by running:
2.2 Changing the Docker Root Direction
Relocating the Docker root directory on a Raspberry Pi 5 involves changing the directory where Docker stores all its data, including images, containers, volumes, and configurations. Docker uses /var/lib/docker as the root directory by default. If you want to move this directory to a different location, follow these steps:
Step 1: Stop the Docker Service
Step 2: Create the New Docker Directory
Step 3: Move the Existing Docker Data
Step 4: Update Docker Configuration
Step 5: Start the Docker Service
Step 6: Verify the Change
Step 7: Clean Up (Optional)
You have successfully relocated the Docker root directory on your Raspberry Pi 5. Docker should now store all its data in the new directory you specified. This can be particularly useful if you're running low on space on the default filesystem or have a faster or larger storage option.