Notes »

Nextcloud Using Docker

Pre-thinking and research

The past couple days I've been looking at tutorials on how to get Nextcloud running using docker and am about to give it a go myself.

Ideally I'm looking for this kind of deploy:

Docker compose deploy on the home server (my Void box that's currently mainly running Jellyfin) using residential ISP so we'll have to use dynamic DNS. My router is a TP-Link and includes easy access to the service, so I used that but discovered Let's Encrypt might not be able to issue a cert for it. I did a CNAME entry on one of my domain names (pointing to the tplinkdns name) and hopefully I'll be able to get a cert for that.

Using Caddy to reverse proxy to the Nexcloud instance along with PostgreSQL (willing to swap this out for MariaDB).

I've been looking over this tutorial while figuring out docker and docker-compose. It seems like he's running an Apache container and then reverse proxying to Caddy from Apache... seems like overkill, but maybe he had trouble getting the 'fpm' tagged container working.

I'm going to attempt to use the stable-fpm-alpine (docs showing different containers and tags), the alpine image should make debugging easier, and using a 'docker network' along with the Caddy reverse proxy container I should be able to skip using Apache.

This guy's recipes seem to align more with how I think: blazekjan's Docker compose github and his Caddy Docker proxy compose

Actual steps

Installed docker and enabled the docker service on the Void server

mkdir ~/docker/{caddy,docker}

cd nextcloud
vim compose.yaml

filling in db user/pass for Postgres and Redis. Signed up for SendGrid and got an API key

docker compose up -d

~docker magic~ it's pulling, extracting, containerizing... error: network caddy declared as external, but could not be found

Looks like we need to create a docker network labeled caddy first:

docker network create caddy

Running the compose up command again worked, now on to the caddy container:

cd ../caddy
vim compose.yaml

created the .env file in the caddy dir, with the DOCKERDIR variable

docker compose up -d

And it's started! Now to get NAT firewall setup to let traffic through

ufw allow http
ufw allow https

also followed instructions for editing the config.php in the post-install instructions.

Restarting the server to see if we can get the HTTP cert through...

Looks like the cert has been acquired and it's serving up an error:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

Looking at the nextcloud logs in $DOCKERDIR/nextcloud/nextcloud_data/data/nextcloud.log there's an issue connecting to the DB:

Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at \"nextcloud-db\" (, port 5432 failed: Connection refused

I fiddled around, but still kept getting the same error, trying to swap Postgres for MariaDB

Swapped Postgres out for Maria and realized the nextcloud.log file wasn't updating, there were only 2 lines and when I deleted the file, it didn't come back... turns out my "fiddling" didn't do anything because I had old data in the volumes, after deleting the volumes and running my mariadb edited docker-compose, it worked!

6/4/23: To access your Nextcloud instance locally just add an entry in your /etc/hosts, or setup "split horizon" DNS if you run a local DNS server (I don't)

The entry should resolve your CNAME domain that points to your dynamic DNS (or your DDNS name if you were able to get a LE cert) to your local IP like so: nc.example


Docker recipes

nuke it all: $ docker rm -f $(docker container ls -a -q)

restart it all: $ docker restart $(docker ps -q)

edit SideBar

Page last modified on July 11, 2023, at 05:08 am