Docker uses nextcloud to build a private Baidu cloud disk

Docker uses nextcloud to build a private Baidu cloud disk

Suddenly, I needed to build a private service for document storage and collaboration. After searching many places, I found that onlyoffice service can meet my document editing needs. For storage, I can use nextcloud to build a private cloud disk service. In this way, using nextcloud+onlyoffice can meet my document online collaborative storage needs. In fact, it is a private cloud disk that can edit and share files such as ofiice.

In the early stage, I used traditional images to start one by one, and then I switched to docker-compose for deployment, so I also provided two solutions. Another point is that my database uses postgresql, the system also supports mysql and MariaDB, or directly use the built-in sqLite. If you use mysql, the configuration of MariaDB is similar to my postgresql. The built-in sqLite is much simpler. Just ignore all the operations of the database in the article.

text

Install and start the service

Method 1: traditional deployment, method 2: docker-compose deployment. The second method is recommended because it is simple.

No matter which one, install docker first
Docker installation under Linux

Method 1

Pull nextcloud image and database image

Database mirroring is optional. You can also use mysql or directly use the built-in sqlLite of nextcloud. I use postgresql here. Also, because I need to operate office, I also installed the onlyoffice service, which can be ignored.

docker pull docker.io/nextcloud
docker pull postgres
docker pull onlyoffice/documentserver

Create and start the container

If you do not use the built-in database, you first need to initialize the database storage warehouse. I created a cloud warehouse specifically for storing data and started it.

Start the database (optional)

docker run --restart=always --name postgresql -v /etc/localtime:/etc/localtime -v /data/postgresql:/var/lib/postgresql/data -e POSTGRES_PASSWORD=123456 -d -p 35432:5432 postgres

-e POSTGRES_PASSWORD=123456 means the default database password is 123456

Start the office service (optional)

docker run --name onlyoffice -i -t -d -p 9000:80 onlyoffice/documentserver

Start nextcloud

docker run --restart=always --name nextcloud -p 8080:80 -v /nextcloud:/var/www/html --link postgresql:postgresql -d nextcloud

-name nextcloud sets the container name

--restart=always means always restarting automatically, and restarting the container after shutting down or restarting the machine

-p 8080:80 means mapping the local port 8080 to the port 80 in the container, which means you need the local ip:8080 when you want to access it (you can choose the port you want).

-v /nextcloud:/var/www/html is used to map container-related resources to the local /nextcloud directory (you can choose your own directory) to facilitate data persistence and external modification of page configuration, etc.

--link postgresql:postgresql is not required, link the postgresql database container for easy configuration (the function will be described in detail later)

Method 2

Install docker-compose

curl -L https://github.com/docker/compose/releases/download/1.10.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Writing a docker-compose file

Create a dedicated folder. Take nextcloud as an example and create a docker-compose.yml file in it.

version: '2'
services:
 nextcloud:
  container_name: nextcloud_app
  image: nextcloud
  ports:
   - "8080:80"
  volumes:
   - ./app:/var/www/html
  links:
   - postgresql
  restart: always

 onlyoffice:
  container_name: nextcloud_office
  image: onlyoffice/documentserver
  ports:
   - "9000:80"
  restart: always

 postgresql:
  container_name: nextcloud_db
  image: postgres:11.4
  environment:
   - POSTGRES_PASSWORD:123456
  volumes:
   - ./postgresql:/var/lib/postgresql/data
   - /etc/localtime:/etc/localtime
  restart: always

networks:
 default:
  external:
   name: nextcloud

Start the container

Operate in the same directory as docker-compose.yml.
The image will be automatically pulled when it is started for the first time, so an Internet connection is required. And the network connection method is used, and a net bridge must be created manually.
Create a net:

docker network create nextcloud

start up:

docker-compose up -d

After the above services are officially started, the next step is configuration.

Initial configuration

Browser access ip:8080

4.1 Enter the administrator account password

4.2 It is recommended to keep the data directory unchanged and use the default

4.3 Database Selection

Built-in SQLite database, fewer storage files, you can just choose the default installation to complete it.

If you choose other databases, take PostgreSQL as an example:

The database username and password need not be mentioned, the database name corresponding to the database needs to be created in advance.

The most important database host is the database access IP + port number.

注: But does the postgresql I filled in look familiar? Yes, it is --link (the net method used in method 2, with the same purpose). My database also uses a docker container. Using --link can pass the PostgreSQL database container as an alias, so here you can directly use postgresql to represent the database (this is a communication method between docker containers. Note that the PostgreSQL container must be started before the nextcloud container).

Whitelist configuration and use

If you need a domain name and some new IP ports to access, you need to modify the configuration in /nextclou/config/config.php (please add it if it is not available)

 'trusted_domains' =>
 array (
  0 => 'www.xxx.com:10080',
 ),

Then you can explore the configuration of the mailbox by yourself.

Configure onlyoffice (not necessary, I just want to operate word online, etc.)

Log in to the cloud disk as an administrator, click User->Apps to install the ONLYOFFICE plugin:


Then go to User->Settings->ONLYOFFICE and fill in the address of your service.


Effect picture:

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Tutorial on building nextcloud personal network disk with Docker
  • Docker+nextcloud to build a personal cloud storage system
  • How to deploy nextcloud network disk using docker
  • How to install and deploy NextCloud private network disk using docker

<<:  MySQL latest version 8.0.17 decompression version installation tutorial

>>:  Vue implements a simple timer component

Recommend

Docker adds a bridge and sets the IP address range

I don't know if it's because the binary d...

Example of how to configure nginx in centos server

Download the secure terminal MobaXterm_Personal F...

Detailed explanation of the principle of Docker image layering

Base image The base image has two meanings: Does ...

JavaScript drag time drag case detailed explanation

Table of contents DragEvent Interface DataTransfe...

How to decompress multiple files using the unzip command in Linux

Solution to the problem that there is no unzip co...

Writing tab effects with JS

This article example shares the specific code for...

Detailed analysis of when tomcat writes back the response datagram

The question arises This question arose when I wa...

A brief analysis of HTML space code

How much do you know about HTML? If you are learni...

Complete steps to use samba to share folders in CentOS 7

Preface Samba is a free software that implements ...

Several ways to improve the readability of web pages

1. Use contrasting colours. The contrast here ref...

CSS web page responsive layout to automatically adapt to PC/Pad/Phone devices

Preface There are many devices nowadays, includin...

Use of Linux stat command

1. Command Introduction The stat command is used ...

Several ways to center a box in Web development

1. Record several methods of centering the box: 1...