I'm a bit new to Docker and need some advice. I've set up my Docker containers on a Raspberry Pi 4, with all my important data stored on separate drives using volumes. Now, I want to transfer these containers to a Raspberry Pi 5 that I'll be booting from an SSD over SATA. If I use the same docker-compose file and point to the same data paths, do I need to reconfigure everything for the Raspberry Pi 5, or can I keep the same setup as on the Pi 4?
4 Answers
As long as your Docker app data and configurations are persistent, you shouldn't have any major issues when moving to the new device.
Yes, your plan should work well! Just make sure that the volumes are mapped correctly and you should be good to go.
If you're asking whether your data will transfer automatically when you run the compose file on the new Raspberry Pi, the answer is no. New volumes will be created on the new host. To back up your data, you could use a command like this to create a tarball of your volume and then load it onto the new host. Here’s how to do it:
```bash
docker run --rm
-v :/volume
-v $(pwd):/backup
busybox
tar czf /backup/backup.tar.gz -C /volume .
```
Then copy that tarball over to the new host and restore it into a new volume with this command:
```bash
docker run --rm
-v :/volume
-v /path/to/destination:/backup
busybox
sh -c "cd /volume && tar xzf /backup/backup.tar.gz"
```
Sorry about the formatting, I'm on mobile!
I've faced a similar issue before, but in a Windows environment. What I ended up doing was writing a PowerShell script to back up the containers and their data, which I compressed into a tar file. This method allowed me to move the setup easily between Windows and Linux. If you're interested, I can share details about the script I created!
Could you share the script? That sounds super useful!
Thanks for the detailed instructions!