Nextcloud & mariaDB Docker-Compose Installation

hello everyone,

I am installing the latest version of Nextcloud on the Raspberry Pi 4 computer with Ubuntu Server.

I would also like to install DBMS mariaDB for use with Nextcloud.

The two installations were in Docker mode.

Here are some questions / problems encountered during the installation of Nextcloud:

  1. Is it possible to install mariaDB, also, in Docker mode or does it have to be an external DBMS?

  2. I installed it through ‘Docker-Compose Up’, with the option “links: - db”, suggested on the website https://hub.docker.com/_/nextcloud.

  3. How to use directories other than those suggested by the applications? I would like to use USB drives. I tried different ways but I couldn’t.

  4. I was only successful in the installation when I used SQLite DBMS and in the directories suggested by the Nextcloud application.

  5. In the mariaDB option, upon confirming the configuration, on the first page I received the “connection refused” error. Is there anything left to do?

Cut out the text on the website.

"Base version - apache
This version will use the apache image and add a mariaDB container. The volumes are set to keep your data persistent. "

What does the above statement really mean?

Below my YML file. The last attempt to install Nextcloud and mariaDB:

I remember that it only worked when I chose SQLite DBMS.
"
version: ‘2’

volumes:
nextcloud:
db:

services:
db:
image: mariadb
command: --transaction-isolation = READ-COMMITTED --binlog-format = ROW
restart: always
volumes:
- db: / var / lib / mysql
environment:
- MYSQL_ROOT_PASSWORD = xxxxxx
- MYSQL_PASSWORD = xxxxxx
- MYSQL_DATABASE = DBnextcloud
- MYSQL_USER = nextcloud
- MYSQL_HOST = 0.0.0.0: 3306

app:
image: nextcloud
ports:
- 8080: 80
links:
- db
volumes:
- nextcloud: / var / www / html
environment:
- NEXTCLOUD_TRUSTED_DOMAINS = 192.168.1.250
restart: always
"

Docker-Compose output:

"
ubuntu @ ubuntu: ~ $ sudo docker-compose up -d

Creating network “ubuntu_default” with the default driver
Creating volume “ubuntu_db” with default driver
Creating volume “ubuntu_nextcloud” with default driver
Creating ubuntu_db_1 …
Creating ubuntu_db_1 … done
Creating ubuntu_app_1 …
Creating ubuntu_app_1 … done
"

Sorry for the question being too big.

I thank you for your help.

in time.

Someone would know how to answer item 3, Thank you.

this will map any host directory (where you mount the usb drive) into the container:
docker run ... -v /local/path/on/host:/path/in/docker/container ...

in docker-compose files you use the volume: section.

note: if the left part doesn’t start with a / it’s a docker volume that you find somewhere in /var/lib/docker/...

you may run docker inspect app to get the full path.

that’s what docker is about. put everything in containers.

and please use a line with three ``` before and after to quote docker-compose files. (this forum uses markdown language to format text.)

Thank you very much Reiner_Nippes.

I still have some issues with MariaDB.

Below is the information.

I redid the installation and got some successes:

  1. Resolved the issue of directories. See the YML file (according to the Reiner_Nippes post). The secret was not to define these directories, but to leave the definition to the containers.

  2. Still showing the error below. Did the “Links: - db” not work?

Error while trying to create admin user:
Failed to connect to the database:
An exception occurred in driver:
SQLSTATE [HY000] [2002] Connection refused

Partial output from Docker-Compose:
"
.
.
.
db_1 | 2020-03-21 17: 33: 13 + 00: 00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
db_1 |
db_1 | 2020-03-21 17:33:13 0 [Note] mysqld (mysqld 10.4.12-MariaDB-1: 10.4.12 + maria ~ bionic) starting as process 1 …
db_1 | 2020-03-21 17:33:13 0 [Warning] You need to use --log-bin to make --binlog-format work.
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Using Linux native AIO
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Uses event mutexes
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Number of pools: 1
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Using generic crc32 instructions
db_1 | 2020-03-21 17:33:13 0 [Note] mysqld: O_TMPFILE is not supported on / tmp (disabling future attempts)
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Completed initialization of buffer pool
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority ().
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Setting file ‘./ibtmp1’ size to 12 MB. Physically writing the file full; Please wait …
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: File ‘./ibtmp1’ size is now 12 MB.
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: 10.4.12 started; log sequence number 60990; transaction id 21
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Loading buffer pool (s) from / var / lib / mysql / ib_buffer_pool
db_1 | 2020-03-21 17:33:13 0 [Note] Plugin ‘FEEDBACK’ is disabled.
db_1 | 2020-03-21 17:33:13 0 [Note] Server socket created on IP: ‘::’.
db_1 | 2020-03-21 17:33:13 0 [Warning] ‘proxies_priv’ entry ‘@% root @ 6d0ef43048b3’ ignored in --skip-name-resolve mode.
db_1 | 2020-03-21 17:33:13 0 [Note] InnoDB: Buffer pool (s) load completed at 200321 17:33:13
db_1 | 2020-03-21 17:33:13 0 [Note] Reading of all Master_info entries succeeded
db_1 | 2020-03-21 17:33:13 0 [Note] Added new Master_info ‘’ to hash table
db_1 | 2020-03-21 17:33:13 0 [Note] mysqld: ready for connections.
db_1 | Version: '10 .4.12-MariaDB-1: 10.4.12 + maria ~ bionic ‘socket:’ /var/run/mysqld/mysqld.sock 'port: 3306 mariadb.org binary distribution
"

YML file:
"
version: ‘2’

volumes:
nextcloud:
db:

services:
db:
image: mariadb
command: --transaction-isolation = READ-COMMITTED --binlog-format = ROW
restart: always
volumes:
- / media / data / mariadbTest: / var / lib / mysql
environment:
- MYSQL_ROOT_PASSWORD = xxxxxx
- MYSQL_PASSWORD = xxxxxx
- MYSQL_DATABASE = DBnextcloud
- MYSQL_USER = nextcloud
- MYSQL_HOST = 127.0.0.1: 3306

app:
image: nextcloud
ports:
- 8080: 80
links:
- db
volumes:
- / media / data / nextcloudTest: / var / www / html
- / media / data / nextcloudTest / apps: / var / www / html / custom_apps
- / media / data / nextcloudTest / config: / var / www / html / config
- / media / data / nextcloudTest / data: / var / www / html / data
- / media / data / nextcloudTest / themes: / var / www / html / themes
environment:
- NEXTCLOUD_DATA_DIR = / media / data / nextcloudTest / data
- NEXTCLOUD_TRUSTED_DOMAINS = 192.168.1.250 svelloso.ddns.net
restart: always
"

Thank you in advance for your help.

if you try to direct your data dir to the mount point of your host the way you tried above won’t work

in the volumes section you map the containers /var/www/html/data folder to the hosts /media/data/nextcloudTest/data folder. that’s what you want.

but in the enviroment: section you direct nextcloud to store files in the containers folder /media/data/nextcloudTest/data. so there will be no files in /var/www/html/data.

got the problem?

no. that’s not what you want. i couldn’t find the meaning of MYSQL_HOST in the mariadb context but probably you limit the access to 127.0.0.1. bad idea. because each container and the host has it’s own 127.0.0.1. you’ll have three “server” on your raspi: the host + two container. so if you try in the nextcloud container to connect to 127.0.0.1:3306 you won’t connect to the database. omit this line. it’s not needed.

if you setup nextcloud use “db” as the database server name.

or use this variable within the nextcloud section. but again it’s not 127.0.0.1 it’s the name of the database container.
grafik

https://hub.docker.com/_/nextcloud

and please use quotes around your yaml files in this forum.

grafik

Hello Reiner_Nippes,

I made the suggested changes and Bingo! It worked…

One last question. How to remove or modify the IP 127.0.0.1 of mariaDB settings? Or do I have to install everything again?

Congratulations!

I really appreciate your help.

you just remove it from your docker-compose file. and restart everthing.

but if nextcloud is running now it’s ok. so the setting has no influence and is ignored anyway.

Thanks a lot for the help!
Can we close the call? Do you close? How can I close it?