Over this past summer I had the opportunity to intern in Boston at The MITRE Corporation. Through my tasking at the company I was able to learn DevOps tooling such as Kubernetes and Docker. This ignited a passion in me to create my own testbed and start experimenting with the different technologies I was learning about. One of the cooler things I deployed was a private google drive alternative called Nextcloud which was selfhosted on my domain. In this post I'll be showing you how to deploy your own instance of the service from scratch.
Setting up Your Environment
First things first we need to install Docker Engine:
sudo apt-get update sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Now we need to create the file structure for our home lab. This will help us greatly down the line when we're trying to add more services to our stack by keeping it clean and organized.
cd ~ mkdir homelab cd homelab mkdir appdata touch docker-compose.yml
Building the Stack
Finally it's time to write our compose file. Copy the following into docker-compose.yml:
version: "3.9" x-environment: &default-environment PUID: 1000 PGID: 1000 TZ: America/New_York #replace with your timezone services: nextcloud: image: lscr.io/linuxserver/nextcloud:latest container_name: nextcloud environment: <<: *default-environment volumes: - ./appdata/nextcloud:/config #holds config files for the container - /location/for/storage:/data #where you keep the stored data ports: - 443:443 restart: unless-stopped
Now run the next line to deploy:
sudo docker compose up
Accessing your Nextcloud Instance
Navigate to https://localhost:443 in your browser:
Create the admin account and click install. Congratulations, you have your own private google drive!