DEV Community

Ameni Nuretemo
Ameni Nuretemo

Posted on

Easily Build Your Own Private Cloud Storage with Nextcloud and Docker

1. Introduction

  • Why build your own?
  • Storing large amounts of data on public cloud services can be expensive.
  • I wanted to set up my own storage server in a local environment to save costs.

  • Why Nextcloud + Docker?

  • Ease of Setup: Get up and running quickly.

  • Simple Maintenance: Easy to update and manage containers.

2. Environment

  • OS: Debian Linux
  • Prerequisites: A system where Docker and Docker Compose can be installed.

3. Step-by-Step Guide

  1. Install Docker
sudo apt install docker.io docker-compose-plugin
Enter fullscreen mode Exit fullscreen mode
  1. Create a Working Directory
mkdir nextcloud
cd nextcloud
Enter fullscreen mode Exit fullscreen mode
  1. Create `docker-compose.yml`
nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode
services:

db:
    image: mariadb:10.11
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - nextcloud_db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}

app:
    image: nextcloud:apache
    restart: always
    ports:
      - 8080:80
    depends_on:
      - db
    volumes:
      - nextcloud_data:/var/www/html
    environment:
      MYSQL_HOST: db
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}

    volumes:
      nextcloud_db:
      nextcloud_data:
Enter fullscreen mode Exit fullscreen mode
  1. Create .env file
nano .env
Enter fullscreen mode Exit fullscreen mode
MYSQL_ROOT_PASSWORD=change-me
MYSQL_PASSWORD=change-me
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
Enter fullscreen mode Exit fullscreen mode
  1. Launch Containers
docker compose up -d
Enter fullscreen mode Exit fullscreen mode

4. Post-Installation & Operation

  • Initial Setup via Browser
  • Access http://localhost:8080 and create an admin account.
  • Tip: Most DB settings from your .env file will be auto-filled. Just double-check them!

  • Useful Commands

  • Status check, Update, Start/Stop, and Logs.

5. Conclusion & Security

  • Personal Reflection: Using Docker makes maintenance incredibly easy.
  • Important Security Note: This setup is not encrypted (No SSL). If you plan to access it from the internet, please use a Reverse Proxy or a tool like Tailscale.

Top comments (0)