Chandan
Chandan
I am a Linux Engineer by profession and a self-hosting hobbyist, I love to deploy, test, self-host my services and have control over my data with respect to security,privacy.

Deploy Nextcloud on Docker

- Advertisement -

Today you will learn how to deploy Nextcloud on Docker

Nextcloud is a suite of client-server software for creating and using file hosting services. It is enterprise-ready with comprehensive support options. Being free and open-source software, anyone is allowed to install and operate it on their own private server devices.

Pre-requisites:

Docker and Docker compose installed
I am using Ubuntu 22.04 here and you can install docker from here and docker compose from here

deploy Nextcloud on Docker:

Nextcloud would use a database container to store all the credentials, etc. You can create a new database container or use an existing one by creating a new database for nextcloud and providing Nextcloud the access to that database. You can even use any managed/unmanaged database from any cloud provider which has less latency from your infrastructure.

version: "3"
services:
  nextcloud:
    image: lscr.io/linuxserver/nextcloud
    container_name: nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/New_York
      - REDIS_HOST=redis
      - REDIS_HOST_PORT=6379
      - REDIS_HOST_PASSWORD=YOUR_PASSWORD_HERE
    volumes:
      - /path/to/nextcloud/config:/config
      - /path/to/nextcloud/data:/data
    restart: always
    ports:
      - 443:443
    networks:
      ## Change nextcloud to the name of your docker network or you can remove this option to use the default bridge docker network
       - nextcloud

  mariadb:
    image: lscr.io/linuxserver/mariadb
    container_name: mariadb
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD= #YOUR_PASSWORD_HERE
      - TZ=America/New_York
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER= #YOUR_DB_USER_HERE
      - MYSQL_PASSWORD= #YOUR_DB_PASSWORD_HERE
    volumes:
      - /path/to/mariadb/config:/config

    restart: always
    networks:
    ## Change nextcloud to the name of your docker network or you can remove this option to use the default bridge docker network
       - nextcloud

  redis:
    image: redis:latest
    restart: always
    container_name: redis
    hostname: redis
    environment:
      REDIS_PASSWORD: #YOUR_REDIS_PASSWORD_HERE
    volumes:
      - /path/to/redis/data:/data
    networks:
    ## Change nextcloud to the name of your docker network or you can remove this option to use the default bridge docker network
      - nextcloud

## Skip the below lines if you are using bridge network or replace with your network name 
networks:
  nextcloud:
    external: true
docker-compose.yml
Directory Structure used by me

You need to change with your credentials and path in above compose file.

Here I am using port 443 to expose Nextcloud. Database and Redis are not exposed to host for security reasons. Feel free to do it if you know what you are doing.

Use docker-compose up -d to pull and run the containers.

docker-compose up -d

Access the Nextcloud using your https://HOST:IP Nextcloud uses a self-signed SSL Certificate and you need to proceed with SSL Prompt.

SSL Prompt

Initially you would be asked to provide Database credentials, host and port. Fill them and complete the installation.

Initial Setup
- Advertisement -

Nextcloud is now fully deployed using docker

Nextcloud Dashboard

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook

x