Install Nextcloud with mysql docker

Hello
I’m trying to install nextcloud using a mysql docker but i have some problems.
On my server running Ubuntu 18.04, i have already a Zimbra OpenSource install and so i cannot install mysql-servver ou mariadb server because zimbra use is own mysql server …
So, the solution to install nextcloud on the same server, is to install mysql-server on a docker.
I install docker and do this to setup mysql:
#> docker run --name=mysql-nextcloud --restart=always -e MYSQL_ROOT_HOST=% -p 3306:3306 -d mysql/mysql-server:5.7
#> docker exec -it mysql-nextcloud mysql -u root -p
when connecting to mysql i setup this:
mysql> CREATE DATABASE nextcloud;
mysql> GRANT ALL PRIVELEGES ON . TO ‘nextcloud’@’%’ IDENTIFIED BY ‘mypassword’;
now, when i try to install nextcloud i enter :

  • admin user: admin-nextcloud
  • passe : testtest
    -data directory : /hdd/raid1/nextcloud-data
    -database-user: nextcloud
  • database-pass: mypassword
  • databae: nextcloud
  • host : 127.0.0.1:3306
    but i have the error :
    Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user ‘oc_admin-nextclo’@’%’ to database ‘nextcloud’

if i try with root i have:
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user ‘root’@‘172.17.0.1’ (using password: YES)

if i try with newtcloud user and the ip of docker (wich i found with docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ mysql-nextcloud), i have the same error :
Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [1044] Access denied for user ‘oc_admin-nextcl1’@’%’ to database 'nextcloud

if someone can help me …
And sorry for my bad english
thanks all!

two things:

1 Like

Excuse me i’ll try this on this afternoon (i forget when i postes that i’m not at Home until this afternoon). Can we install nextcloud on docker ans have data directly on thé Host disk?
I’ll try first with env variables.
Thanks;)

sure.

if you want to keep data persistent with docker you put them into a volume. a volume is a directory on the host that is not deleted when you delete/remove the container and therefore can be reused with another container. (e.g. when you update nextcloud.)

if you choose an absolute path e.g. -v /opt/nextcloud:/var/www/nextcloud/data you’ll find all your data in /opt/nextcloud. if you choose something like nextcloud as a volume name you’ll have to look in /var/lib/docker/volumes.
the second methode is the better one. you don’t get confused with file ownership and security. docker will take care about.

Merci Reiner_Nippes
Avec les options MYSQL_DATABASE, MYSL_USER et MYSQL_PASSWORD quand je crée le docker, plus l’@IP du docker dans l’installeur de nextcloud cela fonctionne.
Ma question par contre est: est-ce que l’@IP du container peut changer? comment la fixer?

ex:
pour créer la data-base:
#> docker run --name=mysql-nextcloud --restart=always -e MYSQL_ROOT_HOST=% -e MYSQL_DATABASE=nextcloud-db -e MYSQL_USER=nextcloud -e MYSQL_PASSWORD=nextcloud -p 3306:3306 -d mysql/mysql-server:5.7
pour voir l’adresse ip du container:
#> docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ mysql-nextcloud

Je marquerais comme résolu dès que j’aurais la réponse à ma dernière question, en tout cas merci beaucoup :smiley:

docker has an internal dns. and the name of the container is the internal dns name of your “db server”. so use mysql-nextcloud instead of ip adress.

and don’t expose the port. omit the following. normally you don’t want to access the db from outside the docker network.

all works good. thanks :smiley: