How I turned my Raspberry Pi into a private cloud server
I do like travelling and taking pictures, even if most of them are really pointless 😄
Once back at home, I’m used to move all the pictures I took on my laptop and, after a selection, I upload the best pictures to the cloud. I like using Google Photos. But there’s a problem. Since I use the Free plan, I don’t upload pictures with the original size. It means they lose quality.
That’s why I decided to buy an HDD and to upload my pictures on it, not using Google Photos anymore.
Damn I miss it.
I don’t have access to my pictures anymore when I’m not around my HDD. Showing and/or sharing them’s impossible.
That’s when the idea of the private cloud started floating in my mind.
You may say buying a HDD wasn’t a cost? Pay for Google Photos then! You’re right but nothing is better than the satisfaction you get by something built by yourself. I really like doing this kind of things so I made my private Google Photos! It’s a full private cloud service actually - documents, video, images, emails, etc - but I use it only for my pictures.
Raspberry Pi and Micro SD
To setup my photo server I used a Raspberry Pi 4 (4 GB RAM) with 16 GB Micro SD and an external USB drive to use as storage.
Docker and Docker Compose 🐳
I also installed Docker on my Raspberry Pi: I didn’t want to re-install everything in case something goes wrong.
Once installed, I did make sure the user
pi can use it (I don’t want to use
sudo every time)
Since the architecture of the Raspberry Pi is different than the classic Ubuntu’s, I needed to install Docker Compose via
To setup Nextcloud I used a
yml file contains the infrastructure I want to build. This way to build infrastructures is called IaC, Infrastructure as Code: you declare the services you want to run and how they have to communicate each other and Docker Compose does the job for you.
In this case, I declared I want to use the
nextcloud image to run an app on the port
80 if the
8080 is busy). I also specified the path for the
volume - where the container stores data (my photos).
Up and running
Now that the
docker-compose.yml is ready, it’s time to launch 🚀
-d stands for
detached mode, containers run in background.
To check if the container we declared in the
yml file is up and running, run
I can do something similar with Docker Compose. Within the root folder that contains the
docker-componse.yml file, run
The difference between
docker ps and
docker-compose ps is that
docker ps lists all running containers in docker engine while
docker-compose ps lists containers related to images declared in the
If you’re on your Raspberry, go to
http://localhost:8080/. If you’re connected to the Raspberry Pi via SSH instead, open a browser and go to
If you don’t know the IP address of your Raspberry Pi, just run
1 2 3
hostname -I 192.168.1.162 172.17.0.1 172.29.0.1 169.254.70.85 172.21.0.1 169.254.52.242 2a00:23c7:8e8b:1201:f35:95a7:4c14:6ed
So, in my case, my Raspberry’s IP address is
192.168.1.162. It shouldn’t change until you disconnect the Raspberry from the Internet > or you restart the router.
Here’s a good article about how to connect via SSH to your Raspberry Pi.
Ta-da! Nextcloud is up and running, ready to use! 🎉 🎉 🎉
Setup the administrator account and do not change the storage and database settings. It’s not time for that yet.
Let’s take a closer look
Sweet, Nextcloud is working and is reachable only within my WiFi connection. I can upload photos from my smartphone too!
Let’s take a look at the container now. Run
and copy the container id. Now run
to enter the container itself, in interactive mode
-it using the
What you will see is something like
You entered the container as
root and it’s waiting for a command. So, let’s discover where the container will store my pictures. The volume path is
/var/www/html. In this container you have Apache running, that’s where
/var/www comes from.
To list all the files run
ls -l. To discover where Nextcloud stores my data, let’s open the
config.php file to sneak a peek.
datadirectory, got it!
Here they are, files and folders! Photos are stored into
My private cloud is ready and now I can safely store my HD pictures on it! Sky is the limit!
Not yet 🚫 I do have two limits:
- I can’t upload my photos if I’m not a home
- I can’t upload all the photos I want because of the limited storage capacity of the Micro SD
To overcome these problems are enouhg a domain and an external hard disk 🔜