0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2025-03-14 02:25:08 +01:00
This commit is contained in:
rdxmb 2018-05-07 13:52:33 +00:00 committed by GitHub
commit ca8d30cf1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,49 +41,37 @@ As the fastCGI-Process is not capable of serving static files (style sheets, ima
By default this container uses SQLite for data storage, but the Nextcloud setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB or PostgreSQL database. You can also link a database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. More info is in the docker-compose section.
## Persistent data
The Nextcloud installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. That means your data is saved even if the container crashes, is stopped or deleted.
The Nextcloud installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. That means your data is saved even if the container crashes, is stopped or deleted.
To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder. To achieve this you need one volume for your database container and Nextcloud.
However, for production environments it is recommended to use several named volumes or mounted host folders. This allows changes in `/var/www/html` run by an image upgrade without touching your custom files. It also allows you to get fine grained access to your individual files.
Nextcloud:
- `/var/www/html/` folder where all nextcloud data lives
```console
$ docker run -d \
-v nextcloud:/var/www/html \
nextcloud
```
Database:
- `/var/lib/mysql` MySQL / MariaDB Data
- `/var/lib/postgresql/data` PostgreSQL Data
```console
$ docker run -d \
-v db:/var/lib/mysql \
mariadb
```
If you want to get fine grained access to your individual files, you can mount additional volumes for data, config, your theme and custom apps.
The `data`, `config` are stored in respective subfolders inside `/var/www/html/`. The apps are split into core `apps` (which are shipped with Nextcloud and you don't need to take care of) and a `custom_apps` folder. If you use a custom theme it would go into the `themes` subfolder.
Overview of the folders that can be mounted as volumes:
- `/var/www/html` Main folder, needed for updating
- `/var/www/html/custom_apps` installed / modified apps
- `/var/www/html/config` local configuration
- `/var/www/html/data` the actual data of your Nextcloud
- `/var/www/html/themes/<YOU_CUSTOM_THEME>` theming/branding
- `/var/www/html/config` local configuration
- `/var/www/html/custom_apps` installed / modified apps
- `/var/www/html/themes` custom theming/branding
If you want to use named volumes for all of these it would look like this
```console
$ docker run -d \
-v nextcloud:/var/www/html \
-v apps:/var/www/html/custom_apps \
-v config:/var/www/html/config \
-v data:/var/www/html/data \
-v theme:/var/www/html/themes/<YOUR_CUSTOM_THEME> \
-v config:/var/www/html/config \
-v custom_apps:/var/www/html/custom_apps \
-v themes:/var/www/html/themes \
nextcloud
```
For the database containers, use the specific database-folders as volumes:
```
- `/var/lib/mysql` MySQL / MariaDB Data
- `/var/lib/postgresql/data` PostgreSQL Data
```
So for MariaDB this will look like:
```console
$ docker run -d \
-v db:/var/lib/mysql \
mariadb
```
## Using the Nextcloud command-line interface
To use the [Nextcloud command-line interface](https://docs.nextcloud.com/server/12/admin_manual/configuration_server/occ_command.html) (aka. `occ` command):
```console
@ -129,7 +117,7 @@ The easiest way to get a fully featured and functional setup is using a `docker-
At first make sure you have chosen the right base image (fpm or apache) and added the features you wanted (see below). In every case you want to add a database container and docker volumes to get easy access to your persistent data. When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory! See below for more information.
## Base version - apache
This version will use the apache image and add a mariaDB container. The volumes are set to keep your data persistent. This setup provides **no ssl encryption** and is intended to run behind a proxy.
This version will use the apache image and add a mariaDB container. The volumes are set to keep your data persistent - and allow secure updates when running an new image. This setup provides **no ssl encryption** and is intended to run behind a proxy.
Make sure to set the variables `MYSQL_ROOT_PASSWORD` and `MYSQL_PASSWORD` before you run this setup.
@ -137,7 +125,10 @@ Make sure to set the variables `MYSQL_ROOT_PASSWORD` and `MYSQL_PASSWORD` before
version: '2'
volumes:
nextcloud:
data:
config:
custom_apps:
themes:
db:
services:
@ -151,7 +142,6 @@ services:
- MYSQL_PASSWORD=
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
image: nextcloud
ports:
@ -159,7 +149,10 @@ services:
links:
- db
volumes:
- nextcloud:/var/www/html
- data:/var/www/html/data
- config:/var/www/html/config
- custom_apps:/var/www/html/custom_apps
- themes:/var/www/html/themes
restart: always
```
@ -177,7 +170,10 @@ Make sure to set the variables `MYSQL_ROOT_PASSWORD` and `MYSQL_PASSWORD` before
version: '2'
volumes:
nextcloud:
data:
config:
custom_apps:
themes:
db:
services:
@ -197,7 +193,10 @@ services:
links:
- db
volumes:
- nextcloud:/var/www/html
- data:/var/www/html/data
- config:/var/www/html/config
- custom_apps:/var/www/html/custom_apps
- themes:/var/www/html/themes
restart: always
web:
@ -329,7 +328,7 @@ docker-compose exec app chown -R www-data:www-data /var/www/html/config
```
5. Copy only the custom apps you use (or simply redownload them from the web interface):
```console
docker cp ./apps/ nextcloud_data:/var/www/html/custom_apps
docker cp ./custom_apps/ nextcloud_app_1:/var/www/html/custom_apps
docker-compose exec app chown -R www-data:www-data /var/www/html/custom_apps
```