In this tutorial, I show you how to install Nextcloud as a Docker container using Docker Compose. Nextcloud is a self-hosted alternative to Google Drive, Dropbox, and other cloud storage services - you own your data, you control access, and there are no monthly subscription fees.
I'm using Ubuntu/Pop!_OS for this tutorial, but these steps will work on any Linux system running Docker.
This is a beginner-friendly tutorial - if you have basic command line knowledge and Docker already installed, you can follow along.
0:00 - Intro
0:33 - Prerequisites & what you'll need
1:26 - Checking for available ports
2:55 - Creating the project directory
3:19 - Creating the port-mapping text file
4:28 - Setting up the .env file
6:49 - Creating the docker-compose.yml
10:07 - Starting the containers
10:28 - First login & initial setup
✅ Docker installed
✅ Docker Compose installed
✅ Basic command line knowledge
OS: Pop!_OS (Ubuntu-based)Hardware: Old Dell Precision Tower 5810Background: Former network engineer, now hobbyist self-hosterCreate project directory:
mkdir -p /your/desired/folder/docker/nextcloud # I started using /opt/docker/
cd /
your/
desired/
folder/docker/nextcloud
If port 8080 isn't being used, then leave the docker-compose.yml file port setting as-is skip "Check port range for availability." If port 8080 is already used by another app, continue below.
Check port range for availability:
for port in {5322..5342}; do
if ss -tuln | grep -q ":$port "; then
echo "🔴 Port $port: IN USE"
else
echo "🟢 Port $port: Free"
fi
Track your port mappings (optional):
cd /your/desired/folder/docker # CHANGE THIS
sudo nano port_mappings.txt
Add entries like:
Port App
5322 Nextcloud
cd /your/desired/folder/docker/nextcloud # CHANGE THIS
nano .env
CHANGE THESE
MYSQL_ROOT_PASSWORD=your_secure_password
MYSQL_PASSWORD=your_secure_password
DON'T CHANGE THESE
CHANGE THESE
NEXTCLOUD_ADMIN_USER=your_preferred_username
NEXTCLOUD_ADMIN_PASSWORD=your_admin_password
Then hit the CTL+X buttons to save it, Y to keep the file name the same, and Enter to finally complete the save.
Download the files directly
Grab the docker-compose.yml here: https://codeberg.org/semico6/seths_public_repo/src/branch/main/docker-compose/nextcloud/docker-compose.ymlGrab the .env here: https://codeberg.org/semico6/seths_public_repo/src/branch/main/docker-compose/nextcloud/.envAssuming you saved the file to ~/Downloads, run this command:
mv ~/Downloads/docker-compose.yml /
your/
desired/
folder/docker/nextcloud/ && mv ~/Downloads/.env /
your/
desired/
folder/docker/nextcloud/
Next, open the docker-compose.yml file and edit the sections with comments:
cd /your/desired/folder/docker/nextcloud/
sudo nano /
your/
desired/
folder/docker/nextcloud/docker-compose.yml
Then hit the CTL+X buttons to save it, Y to keep the file name the same, and Enter to finally complete the save.
From a terminal, change to the nextcloud directory:
cd /
your/
desired/
folder/docker/nextcloud
Hopefully you'll see the container status as 'Started' in the command output. If not, leave a comment and I'll try to help.
Open a browser and navigate to: http://localhost:8080 (unless you used a different port. if so, use that port number).
Login with the credentials from your .env file's NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and start playing around with Nextcloud!
Nextcloud documentation: https://docs.nextcloud.comDocker installation guide: https://docs.docker.com/engine/install/Docker Compose installation guide: https://docs.docker.com/compose/install/linux/Change the passwords in the .env file to something securePort 8080 is customizable - use any available portThe .env file keeps sensitive passwords out of your compose fileAll data is stored in the local ./data and ./db directoriesIn future videos, I'll show you:
Adding OnlyOffice for document editingSetting up remote access with a domain nameBacking up your Nextcloud dataAdvanced features and appsDrop them in the comments - I read and respond to all of them.
I'm not a professional sysadmin or developer - I used to be a network engineer, but these days I'm just a hobbyist figuring out self-hosting for my home setup. I share tutorials on digital sovereignty, self-hosting, physical media ownership, and taking control from big tech. If you're interested in owning your digital life instead of renting it, subscribe for more.
#nextcloud #selfhosted #docker #dockercompose #privacy #digitalownership