Or how I learned to stop worrying and love containerisation

I love Nextcloud, it amazing. It’s grown from humble beginnings to some that is (almost) a full Goole docs replacement. I started off running Owncloud since release 3.0, as a replacement for Dropbox as I was always wanted to store more data than the free plan on Dropbox would allow. And the desktop client allowed me to replicate Dropbox functionality where my data didn’t go to a third party and I had as much storage as I could cram into my machine at home. However as soon as Nextcloud was forked nearly 5 years ago I moved over to that as it was more actively developed.

It’s been on my HP microserver running openmediavault, which was on version 4 using the mysql and nginx plugins that were part of openmediavault. This was all fine until version 16 of Nextcloud came out as it required a php version of at least 7.2 and openmediavault 4 only had version 7. 0.

I’d tried the docker plugin for openmediavault 4 but hadn’t grasped the benefit of docker at the time as the plugin required too much manual data entry in the web interface.

My world changed when I saw this post on the openmediavault forums, and I was introduced to docker compose. A tool that enabled anyone to deploy a complete software stack with just a simple yaml file. I was sold, and within a few minutes I had a reverse proxy with SSL certificates, application server, database server and a redis caching server up and running with the latest and greatest version of Nextcloud.

Here’s my docker-compose.yml file should you want to have a go

version: "2"
services:
  nextcloud:
    image: linuxserver/nextcloud
    container_name: nextcloud
    environment:
      - PUID=1000 #change PUID if needed
      - PGID=100  #change PGID if needed
      - TZ=Europe/London #change Time Zone if needed
    volumes:
      - /srv/dev-disk-by-label-disk1/appdata/nextcloud/config:/config #/srv/dev-disk-by-label-disk1 needs to be adjusted
      - /srv/dev-disk-by-label-disk1/appdata/nextcloud/data:/data     #/srv/dev-disk-by-label-disk1 needs to be adjusted
    depends_on:
      - mariadb
#    ports: # uncomment this and the next line if you want to bypass the proxy
#      - 450:443
    restart: unless-stopped
  mariadb:
    image: linuxserver/mariadb
    container_name: nextclouddb
    environment:
      - PUID=1000 #change PUID if needed
      - PGID=100  #change PGID if needed
      - MYSQL_ROOT_PASSWORD=PASSWORDHERE
      - MYSQL_DATABASE=nextcloud

      - TZ=Europe/London #Change Time Zone if needed
    volumes:
      - /srv/dev-disk-by-label-disk1/appdata/nextclouddb:/config    #/srv/dev-disk-by-label-disk1 needs to be adjusted
    restart: unless-stopped
  swag:
    image: linuxserver/swag         #swag is the replacement for letsencrypt (see link below)
    container_name: swag
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000 #change PUID if needed
      - PGID=100  #change PGID if needed
      - TZ=Europe/London # change Time Zone if needed
      - URL=nextcloud.mydomain.com
      - VALIDATION=http

      - [email protected] # define email; required to renew certificate
    volumes:
      - /srv/dev-disk-by-label-disk1/appdata/swag:/config  #/srv/dev-disk-by-label-disk1 needs to be adjusted
    ports:
      - 443:443
      - 82:80
    restart: unless-stopped
  redis:
    image: redis
    container_name: redis
    hostname: redis
    volumes:
      - /srv/dev-disk-by-label-disk1/appdata/redis/data:/data    #--> needs to be changed to your config
    restart: unless-stopped