Forem

Cover image for Setting Up Nextcloud with Docker on an Old Laptop — Your Own Google Drive in 30 Minutes
Sasanka Rath
Sasanka Rath

Posted on

Setting Up Nextcloud with Docker on an Old Laptop — Your Own Google Drive in 30 Minutes

Part 2 of the home server series. A complete, step-by-step guide to installing Docker, running Nextcloud, setting up phone auto-backup, and getting desktop sync working."

In Part 1, I explained why I replaced Google One with a home server and showed the architecture. Now we build it.

This post covers the heart of the setup — Nextcloud running in Docker. By the end of this guide, you'll have a fully working personal cloud that you can access from your browser, sync files from your desktop, and auto-backup photos from your phone.

What you'll need:

  • An old laptop or PC (I'm using an HP Pavilion x360, but anything with 4GB+ RAM works)
  • Ubuntu Server 24.04 LTS installed (the official install guide takes about 15 minutes)
  • A wired or wireless internet connection
  • About 30 minutes

Let's go.


Step 1: Give your server a static IP

Before installing anything, your server needs a fixed IP address on your home network. Without this, your router might assign it a different IP every time it reboots, and nothing will be reachable.

Find your current network details:

ip a
ip route | grep default
Enter fullscreen mode Exit fullscreen mode

Note down your interface name (something like eth0 for Ethernet or wlo1 for WiFi), your current IP, and your gateway IP (usually 192.168.1.1).

Now edit the netplan config:

sudo nano /etc/netplan/00-installer-config.yaml
Enter fullscreen mode Exit fullscreen mode

For a wired connection (recommended — if your laptop doesn't have an Ethernet port, a USB-C to Ethernet adapter works great):

network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 1.1.1.1
          - 8.8.8.8
Enter fullscreen mode Exit fullscreen mode

For a WiFi connection:

network:
  version: 2
  wifis:
    wlo1:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 1.1.1.1
          - 8.8.8.8
      access-points:
        "Your_WiFi_Name":
          password: "your-wifi-password"
Enter fullscreen mode Exit fullscreen mode

Apply the config:

sudo netplan apply
Enter fullscreen mode Exit fullscreen mode

Verify it worked:

ip a | grep 192.168.1.100
Enter fullscreen mode Exit fullscreen mode

You should see your static IP. From now on, your server is always at 192.168.1.100 (or whatever IP you chose).

💡 Pick an IP outside your router's DHCP range. Most routers assign IPs in a range like 192.168.1.2 to 192.168.1.99. Setting your server to 192.168.1.100 avoids conflicts. Check your router's admin page if you're unsure.


Step 2: Install Docker

Docker lets you run Nextcloud in an isolated container — easy to install, easy to update, easy to back up.

# Update packages
sudo apt update && sudo apt upgrade -y

# Install Docker
sudo apt install docker.io docker-compose -y

# Start Docker and enable it on boot
sudo systemctl enable docker
sudo systemctl start docker

# Add your user to the docker group (so you don't need sudo every time)
sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

Log out and log back in for the group change to take effect. Then verify Docker is running:

docker --version
docker compose version
Enter fullscreen mode Exit fullscreen mode

Both should return version numbers. If they do, Docker is ready.


Step 3: Prepare storage directories

Create the folders where Nextcloud will store your files. I use /srv/nas as the root — it's a standard Linux convention for service data.

💡 Running low on built-in storage? You can mount an external USB hard drive and point these directories to it. A 1TB external drive costs around ₹4,000 and instantly doubles your capacity.

# Create folder structure
sudo mkdir -p /srv/nas/photos
sudo mkdir -p /srv/nas/videos
sudo mkdir -p /srv/nas/documents
sudo mkdir -p /srv/nas/nextcloud

# Set ownership so Nextcloud (which runs as www-data) can write to it
sudo chown -R www-data:www-data /srv/nas
Enter fullscreen mode Exit fullscreen mode

This gives you a clean folder structure:

/srv/nas/
├── photos/       ← All your photos
├── videos/       ← Personal videos
├── documents/    ← PDFs, spreadsheets, etc.
└── nextcloud/    ← Nextcloud internal data
Enter fullscreen mode Exit fullscreen mode

Later, when we set up Samba (Part 3), these same folders will be accessible as network drives on your Mac or PC.


Step 4: Create the Docker Compose file

Create a directory for your server configuration and add the compose file:

mkdir -p ~/server
cd ~/server
nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

Paste this:

version: '3'

services:
  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: always
    ports:
      - "8888:80"
    volumes:
      - ./config:/var/www/html
      - /srv/nas:/var/www/html/data
    environment:
      - NEXTCLOUD_TRUSTED_DOMAINS=192.168.1.100
Enter fullscreen mode Exit fullscreen mode

Let me explain what each line does:

  • image: nextcloud:latest — pulls the latest official Nextcloud image
  • container_name: nextcloud — gives the container a clean name
  • restart: always — auto-restarts the container if it crashes or after a reboot
  • ports: "8888:80" — maps port 8888 on your server to port 80 inside the container
  • volumes — mounts your config directory and storage directory into the container
  • NEXTCLOUD_TRUSTED_DOMAINS — tells Nextcloud which addresses are allowed to access it. We'll add more later (your domain, Tailscale IP, etc.)

💡 Why port 8888? Port 80 is reserved for potential future services. A non-standard port also adds a minor layer of obscurity. You can pick any unused port you like.


Step 5: Launch Nextcloud

cd ~/server
docker compose up -d
Enter fullscreen mode Exit fullscreen mode

The -d flag runs it in the background. First time will take a minute or two to download the Nextcloud image.

Check it's running:

docker ps
Enter fullscreen mode Exit fullscreen mode

You should see:

CONTAINER ID   IMAGE              STATUS          PORTS                  NAMES
abc123def456   nextcloud:latest   Up 2 minutes    0.0.0.0:8888->80/tcp   nextcloud
Enter fullscreen mode Exit fullscreen mode

Now open a browser on any device on your home network and go to:

http://192.168.1.100:8888
Enter fullscreen mode Exit fullscreen mode

You'll see the Nextcloud setup screen.


Step 6: Configure Nextcloud

On the setup screen:

  1. Create an admin account — pick a username and a strong password. This is your main login.
  2. Storage & database — select SQLite for simplicity. It's perfectly fine for personal use with 1-3 users. (If you expect more users, you can set up MariaDB/PostgreSQL later.)
  3. Install recommended apps — check this box. It installs Calendar, Contacts, Talk, and other useful apps.

Click Finish setup. Give it a minute to install everything.

Once done, you'll land on the Nextcloud dashboard — your personal cloud is live.


Step 7: Update trusted domains

Nextcloud only allows access from domains/IPs listed in its trusted domains config. Right now it only knows about 192.168.1.100. We need to add more for later parts of this series.

# Enter the Nextcloud container
docker exec -it nextcloud bash

# Edit the config file
apt update && apt install nano -y
nano /var/www/html/config/config.php
Enter fullscreen mode Exit fullscreen mode

Find the trusted_domains section and update it:

'trusted_domains' =>
array (
  0 => '192.168.1.100',
  1 => 'files.yourdomain.com',
  2 => '100.x.x.x',
),
Enter fullscreen mode Exit fullscreen mode

Replace files.yourdomain.com with your actual domain (we'll set this up in Part 4), and 100.x.x.x with your Tailscale IP once you have it. For now, just add placeholder entries — you can always update later.

Save and exit (Ctrl+X, then Y, then Enter). Then exit the container:

exit
Enter fullscreen mode Exit fullscreen mode

Restart Nextcloud to apply:

docker restart nextcloud
Enter fullscreen mode Exit fullscreen mode

Step 8: Set up phone auto-backup

This is the killer feature — every photo you take automatically syncs to your server.

iPhone:

  1. Download Nextcloud from the App Store
  2. Open the app → enter server address: http://192.168.1.100:8888
  3. Log in with your admin credentials
  4. Go to SettingsAuto Upload
  5. Enable it and select which folders to back up (Camera Roll at minimum)

Android:

  1. Download Nextcloud from Play Store
  2. Same steps — enter server address, log in
  3. Go to SettingsAuto Upload
  4. Enable for Camera folder

From now on, every photo and video automatically uploads to /srv/nas/ on your server. No more paying Google for photo storage.

⚠️ This only works when you're on your home WiFi for now. In Part 4, when we set up Tailscale and the public domain, auto-backup will work from anywhere.


Step 9: Set up desktop sync

Mac:

  1. Download the Nextcloud desktop app from nextcloud.com/install
  2. Install and open it
  3. Server address: http://192.168.1.100:8888
  4. Log in with your credentials
  5. Choose a local sync folder on your Mac (e.g., ~/Nextcloud)
  6. Files now sync automatically — like Dropbox or OneDrive

Windows / Linux:

Same process — download the desktop client, point it to your server, and select a sync folder.

You can also access Nextcloud from any browser at http://192.168.1.100:8888 — upload files, create folders, share links, just like Google Drive.


Step 10: Useful Nextcloud commands

A few commands you'll use regularly:

# Check if Nextcloud is running
docker ps

# View Nextcloud logs (useful for debugging)
docker logs nextcloud --tail 50

# Restart Nextcloud
docker restart nextcloud

# Stop everything
cd ~/server && docker compose down

# Start everything
cd ~/server && docker compose up -d

# Force Nextcloud to re-scan files
# (useful after adding files via Samba — covered in Part 3)
docker exec -u www-data nextcloud php occ files:scan --all

# Check disk space
df -h
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

Nextcloud not loading in browser?

  • Check the container is running: docker ps
  • If not running: cd ~/server && docker compose up -d
  • Check logs: docker logs nextcloud --tail 50

"Access through untrusted domain" error?

  • You're accessing from an IP/domain not in trusted_domains
  • Add it to the config as shown in Step 7

Upload fails for large files?

  • Nextcloud's default upload limit might be too low
  • Fix it:
docker exec -it nextcloud bash
echo "upload_max_filesize=16G" > /usr/local/etc/php/conf.d/uploads.ini
echo "post_max_size=16G" >> /usr/local/etc/php/conf.d/uploads.ini
exit
docker restart nextcloud
Enter fullscreen mode Exit fullscreen mode

"Redirect loop" error?

  • Clear your browser cookies for 192.168.1.100
  • Make sure you're using http:// not https:// (we don't have SSL yet — that's Part 4)

What you should have now

After following this guide:

✅ Docker installed and running
✅ Nextcloud accessible at http://192.168.1.100:8888
✅ Storage organized in /srv/nas/ with separate folders for photos, videos, documents
✅ Phone auto-backup working on your home WiFi
✅ Desktop sync client connected
✅ Your own personal Google Drive — running on hardware you own


Hardware recommendations

You don't need to buy anything new to follow this guide — the whole point is using what you already have. But if you want to improve reliability or expand your setup, here's what I'd suggest:

Disclosure: These are affiliate links. If you purchase through them, I earn a small commission at no extra cost to you. I only recommend products I'd actually use.


What's next

📂 Part 3: Turn your server into a NAS with Samba — We'll make these same folders accessible directly in Mac Finder and Windows Explorer as network drives. This is the fastest way to transfer large files — drag and drop, just like a USB drive.

🌐 Part 4: Access your server from anywhere — Tailscale for private access, Oracle Free VPS + frp for public sharing, and SSL for your custom domain.

🔒 Part 5: Security hardening + lessons learned — UFW, Fail2Ban, SSH hardening, and everything I wish I'd known before starting.

All the config files from this series are available in the companion GitHub repo:
👉 github.com/sasrath/homecloud


Hit Follow if you don't want to miss Part 3. And if you run into any issues with the setup, drop a comment — I'll help you debug it.

Your Google Drive replacement is now running. Next up: making it work like a real NAS. 💾

Top comments (0)