Skip to main content

Nextcloud - Docker Setup

Requirements

Steps to follow

  1. Create folder using follow mkdir nextcloud
  2. Use the command ls to verify the folder was created
  3. Move inside the folder nextcloud using the command cd nextcloud
  4. Create a docker-compose.yaml file by running the following command sudo nano docker-compose.yaml

Docker Compose Command

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb:10.6
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD= <DELETE THIS AND ENTER PASSWORD HERE>
      - MYSQL_PASSWORD= <DELETE THIS AND ENTER PASSWORD HERE>
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD= <DELETE THIS AND ENTER PASSWORD HERE>
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

 

Above is the code  required to deploy NextCloud to , this will standup two containers. One container is the MySQL Database and the other is Nextcloud itself.

  1. Copy and paste the code above into the docker-compose.yaml file.

  2.  You need to make sure that your don't change the DATABASE or USER values, (these are on lines 17 and 18 as well as lines 31 and 32). If you do change them you need to make sure they match on both line 17 and 18 as well as line 31 and 32.

  3. What happens here is that when you stand these containers up, Nextcloud should automatically mount to the Database, if you are asked for the Database details in the Nextcloud setup then something went wrong. 

  4. Make sure you updated the values in the code above, so lines 15,16,28,30 need to be updated.

  5. It's compulsory to change lines 15, 16 and 30.

  6. You can technically leave line 13 and 28 which is setting up your storage location for MySQL and Nextcloud containers but it's best practice to have these stored somewhere dedicated.

  7. Once you have the compose file setup, run 'sudo docker-compose up -d'

  8. Containers will be setup and created.

  9. In a browser visit server-local-ip-address:8080