Install Nextcloud
Run the company's own file storage in Docker: folders, share links, calendar and sync with your computer, on Windows or Linux Mint.
Last reviewed:
What you get out of this
When you are done, the company has its own file space. The business plan, the images, the spreadsheets and the minutes are in one place that you own yourselves, everyone can reach them from the browser or the phone, and the files sync to the computer like any other folder. You also get a calendar, task lists and the option to send a sharing link to a customer without attaching a file to an email.
There is one more point, and it is worth taking seriously. When you run Nextcloud yourselves, the company's files sit on a server you have chosen, in a country you have chosen, and you can answer the question of where personal data is stored without guessing. That is exactly the question GDPR is about.
What you need before you start
- Docker installed on a computer with Windows or Linux Mint. The guide Install Docker walks through it step by step, and this guide starts where that one ends.
- At least 4 GB of free memory on the computer. Nextcloud and the database run at the same time and need space.
- 10 GB free on the disk to start with, more if you are going to add a lot of images or video.
- A place where the company stores passwords. You create four of them in this guide and you will need them again. If you do not have such a place, do Install Vaultwarden first.
- Two people who do it together. The person who installs alone also becomes the person who has to step in alone every time something goes wrong.
Time required and difficulty level
Set aside an afternoon for the whole guide. The installation itself takes twenty minutes once Docker is in place, and the rest goes to accounts, sharing and getting the sync to work on everyone's computers. The difficulty level is high for anyone who has never seen a terminal window, but nothing here requires prior knowledge. You paste in a file and run two commands.
What Nextcloud is, and what it is not
Nextcloud is a cloud service that you run yourself. Functionally it is close to Google Drive: files in folders, sharing with a link, version history, trash, comments and a mobile app. The difference is that the software runs on your own computer or your own server instead of at someone else's, and that the license costs zero SEK no matter how many accounts you create.
Be honest about the downside too. If Nextcloud sits on a computer at someone's home in the company, the files are gone as long as the computer is turned off, and whoever owns the computer becomes the company's IT operations department. If Nextcloud is to be the company's real file surface, it belongs on a cloud server that runs around the clock. The installation below is the same on such a server.
Nextcloud does one more thing that is easily missed: you can edit documents together in the browser if you install Nextcloud Office. That is outside this guide, but it is there when you want it.
The files you paste in
Nextcloud needs a database next to it. Instead of installing two things separately, you describe both in one file and start them with a single command.
Create a folder called nextcloud where you usually save files. In it, create a text file called compose.yaml. Use a real text editor, meaning Notepad on Windows or Text Editor on Mint. Word inserts invisible characters that ruin the file.
Check Nextcloud's list of supported database versions before you lock in one. A floating major version like mariadb:11 can over time point to a minor version that is no longer listed as supported.
services:
db:
image: mariadb:11
restart: unless-stopped
command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
volumes:
- db_data:/var/lib/mysql
environment:
- MARIADB_ROOT_PASSWORD=BYT_UT_MIG_1
- MARIADB_DATABASE=nextcloud
- MARIADB_USER=nextcloud
- MARIADB_PASSWORD=BYT_UT_MIG_2
app:
image: nextcloud:stable
restart: unless-stopped
depends_on:
- db
ports:
- "8080:80"
volumes:
- nextcloud_data:/var/www/html
environment:
- MYSQL_HOST=db
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD=BYT_UT_MIG_2
- NEXTCLOUD_ADMIN_USER=admin
- NEXTCLOUD_ADMIN_PASSWORD=BYT_UT_MIG_3
- NEXTCLOUD_TRUSTED_DOMAINS=localhost
volumes:
db_data:
nextcloud_data:
Replace the three lines that shout about it. BYT_UT_MIG_2 appears in two places and must be exactly the same string in both, otherwise Nextcloud cannot reach the database. The passwords must be long and random, and they must be saved where the company stores passwords before you continue.
The indentation in the file matters. Two spaces where it says two spaces, four where it says four, and never tab characters. If the indentation is wrong, Docker responds with an error message about yaml and refuses to start.
Windows: start Nextcloud
Make sure Docker Desktop is running, meaning the options at the bottom left are green. Open PowerShell, go to the folder and start:
cd $HOME\Documents\nextcloud
docker compose up -d
The first time, about one gigabyte is downloaded. It takes a few minutes and the terminal keeps writing lines. When the cursor comes back, run docker compose ps and check that both services show as running.
Then open http://localhost:8080 in the browser. The first load can take half a minute while Nextcloud sets up the database. Log in with the username admin and the password you wrote in the file.
Linux Mint: start Nextcloud
Open Terminal, go to the folder and start with the same command:
cd ~/nextcloud
docker compose up -d
Check with docker compose ps that both db and app are running, and open http://localhost:8080.
On Mint, the official desktop client is also available in Mint's own repository, so syncing is one command away:
sudo apt install nextcloud-desktop
Start the program from the start menu, select Log in, enter http://localhost:8080 as the server address and approve in the browser. The client creates a folder called Nextcloud in your home directory, and everything placed there is synced.
If others in the company need to reach the server from their computers on the same network, they need your IP address. Find it with hostname -I. NEXTCLOUD_TRUSTED_DOMAINS in the compose file is only read by the automatic installation the first time the container starts, so adding the IP address there and running docker compose up -d again makes no difference when Nextcloud is already running. Instead, add the address directly to the running installation:
docker compose exec -u www-data app php occ config:system:set trusted_domains 1 --value=er-ip-adress
If you skip that, Nextcloud responds with Access through untrusted domain, which is one of the most common places to get stuck in this guide.
Basic settings for a company
- Click the profile picture at the top right, select Settings and set language to Swedish and region to Sweden.
- Go to Administration and then Users. Create an account for each person in the company. Do not give everyone administrator rights, two is enough.
- Create groups that follow how you work, for example
ekonomiandmarknad, and share folders with groups instead of with individual people. That way you do not have to start over when someone changes role. - Build the folder structure before you start uploading. Four or five folders at the top level are enough: Business plan, Finance, Marketing, Product, Minutes.
- Install the Calendar app under Apps if you want the company's deadlines in the same place as the files.
Share files with customers and partners
Right-click a file, select Share and then Share link. The link can be sent to anyone. Two settings behind the gear icon are worth using every time you share something outside the company: set an expiration date, and set a password if the file contains anything related to a customer. A share link without an expiration date lives on long after it should have been closed.
If an advisor or partner needs to submit files, create a folder and select Allow upload and editing on the link. Then they can add files without having an account.
Back up
Everything is in two volumes that Docker manages, and volumes survive container deletion. They do not, however, survive a broken disk. Do this once a month, and always before you change anything major:
docker compose exec -T db mariadb-dump -u nextcloud -pBYT_UT_MIG_2 nextcloud --result-file=/tmp/nextcloud-db.sql
docker compose cp db:/tmp/nextcloud-db.sql ./nextcloud-db.sql
docker run --rm -v nextcloud_nextcloud_data:/data -v "$PWD":/backup alpine tar czf /backup/nextcloud-filer.tar.gz /data
The dump is written to a file inside the container and then copied out, instead of being sent to nextcloud-db.sql with >. If you do the latter in PowerShell on Windows, PowerShell writes the file as UTF-16, and it cannot be read back cleanly. If you run in PowerShell on Windows, write -v "${PWD}:/backup" with the curly braces in the third command. $PWD works technically even without them, but the quote character right after can otherwise be interpreted as a separate argument.
The first command takes the database, the second takes the files. The volume name in the second command consists of the folder name plus the volume name, so check with docker volume ls what yours is called before you run. Put both files somewhere other than on the same computer. An external disk or the company's Google Drive is enough, the point is that the copy should not disappear together with the original.
If the company is ever shut down, these two files are your entire history.
How to know it worked
docker compose psshows bothdbandappasrunning.- You log in to
http://localhost:8080with the admin account. - An uploaded file is still there after
docker compose restart. - Everyone in the company can log in with their own account.
- A share link can be opened in a private window, that is, without being logged in.
- The backup exists as two files in a different location than the server.
If something goes wrong
"Access through untrusted domain". The address you are browsing to is not in the list of trusted domains. Add it with docker compose exec -u www-data app php occ config:system:set trusted_domains 1 --value=er-adress. Just changing NEXTCLOUD_TRUSTED_DOMAINS in the compose file and running docker compose up -d again does nothing, that variable is only read on the very first start.
The page does not respond at all right after start. Nextcloud sets up the database on the first start and it takes a while. Run docker compose logs -f app and wait until the lines stop scrolling.
Error message about the database connection. Almost always that MARIADB_PASSWORD and MYSQL_PASSWORD are not identical. Correct the file, run docker compose down -v to throw away the half-finished database, and start again. That flag deletes data, so only run it before you have added anything you want to keep.
Port 8080 is taken. Change the left number in ports to for example 8081:80 and browse to that port instead.
The desktop client refuses to log in. Check that the server address is written with http:// and the port, not just the computer name.
What you do next
Move in for real. A file area that only contains a test document is never used, so add the business plan, the budget and the images on the first day and decide that they live there now. Install the sync client on everyone's computers and the company's phones.
If you want to run Nextcloud on a server that is up around the clock, the steps are the same, but you also need a domain name and HTTPS. Domain and email covers the domain part, and Install Odoo shows how to set up a cloud server from scratch.