setup Nextcloud on Raspberry Pi with Docker: step-by-step instructions

Setting Up Nextcloud on Raspberry Pi with Docker: Step-by-Step Instructions Prerequisites Before starting the setup, make sure you have the following prerequisites in place: Raspberry Pi: Any model from Raspberry Pi 2 and onward is

Written by: David Choi

Published on: January 7, 2026

Setting Up Nextcloud on Raspberry Pi with Docker: Step-by-Step Instructions

Prerequisites

Before starting the setup, make sure you have the following prerequisites in place:

  • Raspberry Pi: Any model from Raspberry Pi 2 and onward is recommended, with at least 2GB of RAM.
  • Operating System: Raspberry Pi OS (formerly Raspbian) Lite or any compatible OS installed.
  • Internet Connection: Ensure your Raspberry Pi has an active internet connection.
  • SSH Access: Optional, but recommended for remote access to your Raspberry Pi.
  • Docker Installed: Follow the instructions below to install Docker.

Step 1: Update Your System

First, ensure your Raspberry Pi’s packages are up-to-date. Open a terminal or SSH into your Raspberry Pi and run the following commands:

sudo apt update
sudo apt upgrade -y
sudo apt install -y curl

Step 2: Install Docker

Next, you will install Docker, which makes it incredibly easy to run applications like Nextcloud in isolated environments. Execute the following command:

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

After Docker is installed, add your user to the Docker group to run Docker commands without sudo:

sudo usermod -aG docker $USER

To apply the changes, either log out and log back in or restart your Raspberry Pi.

Step 3: Install Docker Compose

Docker Compose simplifies the configuration of multi-container applications. To install Docker Compose, run:

sudo apt install -y libffi-dev libssl-dev python3 python3-pip
sudo pip3 install docker-compose

You can verify the installation by checking the version:

docker-compose --version

Step 4: Create the Nextcloud Directory

Next, create a directory where your Nextcloud configuration and files will reside. This keeps your installation organized:

mkdir ~/nextcloud
cd ~/nextcloud

Step 5: Create a Docker Compose File

Now, create a docker-compose.yml file within the Nextcloud directory:

nano docker-compose.yml

Add the following content to the file, which sets up both the Nextcloud and the MariaDB database:

version: '3.1'

services:
  nextcloud:
    image: nextcloud
    ports:
      - "8080:80"
    links:
      - db
    environment:
      MYSQL_PASSWORD: example
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
    volumes:
      - nextcloud_data:/var/www/html

  db:
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_USER: nextcloud
      MYSQL_DATABASE: nextcloud
      MYSQL_PASSWORD: example
    volumes:
      - db_data:/var/lib/mysql

volumes:
  nextcloud_data:
  db_data:

Step 6: Start the Containers

With your docker-compose.yml file created, you are ready to start the containers. Run the following command from inside your nextcloud directory:

docker-compose up -d

This command will download the necessary Docker images and start Nextcloud and MariaDB in detached mode.

Step 7: Access Nextcloud

After the containers have started, you can access your Nextcloud instance by visiting:

http://<your-pi-ip>:8080

Replace <your-pi-ip> with the IP address of your Raspberry Pi. On this page, you will be prompted to create an admin account for your Nextcloud.

Step 8: Configure Nextcloud

During the Nextcloud setup page:

  1. Admin Account: Enter a username and password.

  2. Database Connection: Fill out the database details as follows:

    • Database user: nextcloud
    • Database password: example
    • Database name: nextcloud
    • Host: db
  3. Click the Finish setup button to complete the installation.

Step 9: Setting Up HTTPS with Let’s Encrypt (Optional)

For secure access, you can set up HTTPS using Let’s Encrypt. You will need to install Certbot:

sudo apt install certbot certbot-dns-cloudflare

Then, you need to create the necessary certificates. Additionally, adapt the NGINX configuration or utilize a reverse proxy to manage SSL certificates.

Step 10: Managing Your Nextcloud Instance

You can manage your Docker containers at any time using:

docker-compose ps

To stop the containers:

docker-compose down

To restart them:

docker-compose up -d

Step 11: Update Nextcloud

To update your Nextcloud instance, you’ll need to pull the latest image:

docker-compose pull

Then, restart your services:

docker-compose up -d

Step 12: Backup Your Nextcloud Installation

It’s crucial to regularly back up your Nextcloud data. You can achieve this by backing up the volumes. To create backups, run:

docker run --rm --volumes-from nextcloud -v $(pwd):/backup busybox tar cvf /backup/nextcloud_backup.tar /var/www/html

Step 13: Explore Nextcloud Features

Now that your Nextcloud installation is live, take some time to explore its extensive features, such as file sharing, calendar integration, and collaborative tools, which make it a powerful self-hosted alternative to mainstream cloud services.

Step 14: Advanced Configuration (Optional)

You can further customize your Nextcloud installation by enabling additional apps directly within the Nextcloud interface. Browse the App Store from the settings to explore more functionalities.

Step 15: Monitor Resource Usage

Monitoring your Raspberry Pi’s resource usage is essential, especially if you’re running multiple containers. You can utilize tools like htop or docker stats to keep an eye on both CPU and memory utilization.

Final Touch

Congratulations! You have successfully set up Nextcloud on your Raspberry Pi using Docker. Enjoy your personalized cloud storage solution that ensures privacy and accessibility from anywhere.

Leave a Comment

Previous

beginner’s guide to managing personal finance with gnu cash

Next

beginners guide to using open source video editing tools for YouTube