Deploy Nextcloud on Docker

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

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

Nextcloud is now fully deployed using docker

Nextcloud Dashboard
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

1 COMMENT

  1. Hi Chandan, I have home network with 3 Windows 10 computers. Two of them running Windows 10 Home (for mom and my sister) and the other Windows 10 Pro.
    I also have an old Dell laptop and recently installed Ubuntu 22.04 server. I’d like to set up Nextcloud (running on docker) and give access to all three computers on my network. When following your article instructions, docker-compose attempts to build the container, I stops at “network nextcloud declared as external, but could not be found”. I’m an experienced IT professional, but most of what I do is Web Development, and still a bit new to docker/docker-compose. The only things I changed in the docker-compose are the places you have comments for the root password and username and user password. Any ideas what I’m doing wrong, or not doing at all? 🙂

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook