Docker

Nextcloud Docker Compose

Nextcloud is a free and open-source, self-hosted, and highly extensible platform for secure file storage, synchronization, and sharing.

Nextcloud utilizes a client-server architecture with HTTP and WebDAV protocols to offer advanced features such as data encryption, access control, versioning, and more.

Additionally, Nextcloud features app integration, which allows you to extend its functionality and create custom solutions via APIs.

In this tutorial, we will quickly go over the process of setting up a Nextcloud instance using Docker containers.

Requirements

To run the commands and steps provided in this post, ensure you have the following:

  1. Docker engine installed
  2. Docker compose installed
  3. Sufficient permissions to run Docker containers

Defining Docker Compose File

The first step is defining the Docker compose configuration for running the Docker container. Start by creating the directory to store the config file:

$ mkdir nextcloud

$ cd nextcloud

Create a docker-compose.yml file to run the Elasticsearch cluster as shown in the example configuration below:

---
version: "2.1"
services:
  nextcloud:
    image: lscr.io/linuxserver/nextcloud:latest
    container_name: nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - ./appdata:/config
      - ./data:/data
    ports:
      - 443:443
    restart: unless-stopped

In this example file, we define one service. The Next cloud service allows us to configure the Nextcloud instance.

The service definitions are as expressed below:

  • Use the Nextcloud latest image.
  • Set container name to nextcloud.
  • Define environment variables for user and group IDs (PUID and PGID) and the time zone (TZ).
  • Map the host directories (./appdata and ./data) to container volumes for configuration and data storage.

Finally, we listen on port 443 for HTTPS traffic and is set to automatically restart unless explicitly stopped.

Ensure to replace the above entries with the path to appdata and path to data as necessary.

Run the Container

Once we have the services defined, we can proceed and run the container using the docker compose command as:

$ docker compose up -d

Accessing Elasticsearch and Kibana

Once the containers are started, we can proceed and access the instance at the following addresses:

https://localhost:443 -> Elasticsearch

You will be prompted to configure and administrator account.

Once satisfied, click Install to run the installation process.

Next, you can choose the apps you wish to install in your instance:

This should setup the instance with your desired tools and configurations and take you to the dashboard.

Conclusion

This article covered the fundamental steps of defining and running a Nextcloud instance using docker containers.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list