It seems auto-configuration using environment variables does not work when using docker image "nextcloud:15.0.0-apache".
docker-compose.yml:
version: "2"
services:
nextcloud:
image: nextcloud:15.0.0-apache
container_name: nextcloud
expose:
- "80"
links:
- mariadb
depends_on:
- mariadb
volumes:
- "./data:/var/www/html:z"
environment:
- MYSQL_HOST=mariadb
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_PASS=secretpassword
- NEXTCLOUD_ADMIN_USER=ncadmin
- NEXTCLOUD_ADMIN_PASSWORD=supersecretpassword
restart: always
Results in the first-time wizard having empty admin user/password, sqlite as the chosen database, and when one chooses mysql the mysql infos aren't filled in. So for some reason all those environment variables are ignored by the first-time wizard.
If I start a bash shell in the container, I can see the environment variables there just fine.
I am encountering the same issue.
I'm not able to reproduce this
I'm having the same issue using the example docker container configuration (tried both docker-compose/with-nginx-proxy/mariadb/fpm and docker-compose/with-nginx-proxy/postgres/fpm)
EDIT:
Figured out what my issue is, it's a case of RTFM...
When switching between mariadb and postgres, the environment variables for database name are:
MYSQL_DATABASE and POSTGRES_DB, so a :%s/MYSQL/POSTGRES/g didn't work.
I'm having the same problem. The variables are simply being ignored. Any idea why so many of us have this problem even though you can't reproduce it ?
I used the example in https://github.com/nextcloud/docker/issues/593#issue-394863856
Example in #593? That is this thread ?!?!
I got the same problem, but only on an existing installation. Copy & Pasting the nextcloud parts into a new docker-compose file and starting it works like a charme...
Auto configuration will not overwrite settings if you already have an existing installation. If you are migrating or already have installed nextcloud, you have to edit the config file manually by attaching to the container or copying additional files into the container/volume.
Actually this is a new installation. I have a lot of data that I have so far accessed through CISF/SMB, and the plan now is to install nextcloud/mysql/redis containers to serve files in my local lan as well as on the internet. My lan is behind a pfsense firewall with haproxy and acme/letsencrypt, so I am not concerned with that.
So how do I import my standard windows folder into nextcrypt? I can only find pages talking about migration from owncrypt.
Ok, I realize that is perhaps not really the relevant forum for that question, but how about this:
How can I ensure this is a new installation? I did a "docker compose down", then "docker system prune -a". That ought to have cleaned everything up, yet it still doesn't take the environment variables when I start over. I even went as far as to uninstall docker, remove /var/lib/docker, reinstall docker.
No matter what I do, it still comes up asking for the variables when i connect to the admin page... ?
normally docker-compose down -v should be enough (-v ensures that the created volumes get deleted)
Can you please post your docker-compose file?
Sure:
version: '2'
volumes:
nextcloud:
mariadb:
services:
mariadb:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- /media/usb/share/nextcloud/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=rootpass
- MYSQL_PASSWORD=pass
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
nextcloud:
image: nextcloud
restart: always
ports:
- 80:80
links:
- mariadb
volumes:
- /media/usb/share/nextcloud/data/:/var/www/html/data
environment:
- NEXTCLOUD_ADMIN_USER = admin
- NEXTCLOUD_ADMIN_PASSWORD = adminpass
- NEXTCLOUD_DATA_DIR = /media/usb/share/nextcloud/data/
- NEXTCLOUD_TRUSTED_DOMAINS = 192.168.1.90
You forgot the MySQL info for nextcloud to automatically configure the database connection. That's why the setup page is coming up. You need to add the following variables:
...
- MYSQL_HOST=mariadb
- MYSQL_PASSWORD=pass
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
Ok, I added this info, but it still asks to create an admin account.
Are you sure you started a fresh install? Remove the created volumes with docker-compose down -v
100% sure !
Do I need to manually clear out anything under /var/lib/docker?
Auto configuration will not overwrite settings if you already have an existing installation.
Ok, thanks for clarification - if restored my files and it works again
I think the problem is caused by a race condition.
The first start of MariaDB takes a long time (~2 minutes in my case).
The setup script in the nextcloud docker image only tries a limited number of times to run the install command (for ~30 seconds): https://github.com/nextcloud/docker/blob/2acb1df9ae522ab4c586f4e2e7084e47f9cbf4c6/16.0/apache/entrypoint.sh#L104
the same problem with postgres:
โ nextcloud cat docker-compose.yml
version: '3.3'
services:
db:
image: postgres:12.0-alpine
restart: unless-stopped
volumes:
- ./db:/var/lib/postgresql/data
environment:
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: nextcloud
app:
image: nextcloud:15.0.12-apache
ports:
- 7180:80
links:
- db
volumes:
- ./nextcloud:/var/www/html
restart: always
depends_on:
- db
environment:
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
POSTGRES_DB: nextcloud
POSTGRES_USER: nextcloud
POSTGRES_PASSWORD: nextcloud
POSTGRES_HOST: db:5432
โ nextcloud docker-compose up -d db
Creating nextcloud_db_1 ...
Creating nextcloud_db_1 ... done
โ nextcloud docker-compose logs db
Attaching to nextcloud_db_1
db_1 | 2019-11-01 22:05:02.091 UTC [1] LOG: starting PostgreSQL 12.0 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit
db_1 | 2019-11-01 22:05:02.092 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2019-11-01 22:05:02.092 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2019-11-01 22:05:02.112 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2019-11-01 22:05:02.172 UTC [18] LOG: database system was shut down at 2019-11-01 22:04:35 UTC
db_1 | 2019-11-01 22:05:02.194 UTC [1] LOG: database system is ready to accept connections
โ nextcloud docker-compose up -d app
nextcloud_db_1 is up-to-date
Creating nextcloud_app_1 ...
Creating nextcloud_app_1 ... done
โ nextcloud docker inspect nextcloud_app_1|grep -A 20 Env
"Env": [
"POSTGRES_HOST=db:5432",
"POSTGRES_USER=nextcloud",
"NEXTCLOUD_ADMIN_PASSWORD=admin",
"POSTGRES_PASSWORD=nextcloud",
"NEXTCLOUD_ADMIN_USER=admin",
"POSTGRES_DB=nextcloud",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PHPIZE_DEPS=autoconf \t\tdpkg-dev \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c",
"PHP_INI_DIR=/usr/local/etc/php",
"APACHE_CONFDIR=/etc/apache2",
"APACHE_ENVVARS=/etc/apache2/envvars",
"PHP_EXTRA_BUILD_DEPS=apache2-dev",
"PHP_EXTRA_CONFIGURE_ARGS=--with-apxs2 --disable-cgi",
"PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
"PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
"PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie",
"GPG_KEYS=CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D",
"PHP_VERSION=7.3.11",
"PHP_URL=https://www.php.net/get/php-7.3.11.tar.xz/from/this/mirror",
"PHP_ASC_URL=https://www.php.net/get/php-7.3.11.tar.xz.asc/from/this/mirror",
On the first URL checking I see "Create an admin account" message.
UPD. when I trying to put admin/admin as login and password on that screen, I got that error:
"SQLSTATE[08006] [7] FATAL: permission denied for database "nextcloud" DETAIL: User does not have CONNECT privilege. "
Then I tried to use postgres:11.5:
~ dc logs -f db
Attaching to anton_db_1
...
db_1 | 2019-11-02 08:19:15.358 UTC [1] LOG: database system is ready to accept connections
^CERROR: Aborting.
โ ~ dc up -d app
anton_db_1 is up-to-date
Creating anton_app_1 ... done
-% โ ~ dc logs -f app
Attaching to anton_app_1
app_1 | Initializing nextcloud 15.0.12.1 ...
app_1 | Initializing finished
app_1 | New nextcloud instance
app_1 | Installing with PostgreSQL database
app_1 | starting nextcloud installation
app_1 | Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7] FATAL: permission denied for database "nextcloud"
app_1 | DETAIL: User does not have CONNECT privilege.
app_1 | ->
app_1 | retrying install...
app_1 | Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7] FATAL: permission denied for database "nextcloud"
app_1 | DETAIL: User does not have CONNECT privilege.
app_1 | ->
app_1 | retrying install...
app_1 | Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7] FATAL: permission denied for database "nextcloud"
app_1 | DETAIL: User does not have CONNECT privilege.
app_1 | ->
app_1 | retrying install...
^CERROR: Aborting.
โ ~ dc exec db psql -U nextcloud
psql (11.5 (Debian 11.5-3.pgdg90+1))
Type "help" for help.
nextcloud=# GRANT CONNECT ON DATABASE nextcloud TO nextcloud;
GRANT
nextcloud=# \q
โ ~ dc logs -f app
Attaching to anton_app_1
...
app_1 | ->
app_1 | retrying install...
app_1 | Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7] FATAL: permission denied for database "nextcloud"
app_1 | DETAIL: User does not have CONNECT privilege.
app_1 | ->
app_1 | retrying install...
app_1 | Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7] FATAL: permission denied for database "nextcloud"
app_1 | DETAIL: User does not have CONNECT privilege.
app_1 | ->
app_1 | installing of nextcloud failed!
โ ~
Feels like nextcloud tries to connect with another user. But:
โ ~ dc exec db psql -U nextcloud
psql (11.5 (Debian 11.5-3.pgdg90+1))
Type "help" for help.
nextcloud=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-----------+----------+------------+------------+-------------------------
nextcloud | nextcloud | UTF8 | en_US.utf8 | en_US.utf8 | nextcloud=CTc/nextcloud
postgres | nextcloud | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | nextcloud | UTF8 | en_US.utf8 | en_US.utf8 | =c/nextcloud +
| | | | | nextcloud=CTc/nextcloud
template1 | nextcloud | UTF8 | en_US.utf8 | en_US.utf8 | =c/nextcloud +
| | | | | nextcloud=CTc/nextcloud
(4 rows)
Autoconfig based on ENV Vars is still broken in v17.
Tested with absolute blank system.
same issue in v17, NEXTCLOUD_ADMIN_PASSWORD and NEXTCLOUD_ADMIN_USER not work.
Tried with version 16 and 17 and this issue pops up.
Broken for me too. Possible mitigations:
Mitigation without intervening on the source, for us users consists in removing the faulty Nextcloud volume, and recreating it:
sudo docker volume ls to get the nextcloud volume. It will be called <project_name>_<volume_name> (where project_name is the name of the directory).sudo docker volume rm project_nextcloud will give you an error with the name of the containers using this volume. Take this list, remove the commas, and paste it below:sudo docker container rm <id1, id2, id3...>sudo docker-compose up againIf you haven't ever ran docker-compose up, instead of the above, you can let docker-compose create the db volume first.
Assuming your database service is called db, you can run
sudo docker-compose -f docker-compose.yml up db
Let it do its thang, then kill it, and run:;
sudo docker-compose up
Both those solutions work, which confirms it's a racing condition, though I have no idea why.
would be great to have an argument to auto-configure the nextcloud (triggering the install) when running the container.
This is due a performance regression in recent MariaDB releases, see https://github.com/docker-library/mariadb/issues/262
For anyone that's still struggling with this issue, I was able to come up with a solution in my docker-compose project. The cause of the issue has already been discussed above (mariadb takes ~60 seconds to setup on first launch, whereas nextcloud only performs 10 install attempts. If mariadb doesn't start up before nextcloud, the installation will fail and the parameters won't be applied)...
To resolve it, I mount the wait-for-it script found here https://github.com/vishnubob/wait-for-it into the container, override the entrypoint in my docker-compose file to call the script which then calls the entrypoint when the database container is accepting connections.
volumes:
- ./configs/nextcloud/wait-for-it.sh:/bin/wait-for-it.sh # make sure this file is marked as executable on the host!
entrypoint: sh -c '/bin/wait-for-it.sh nextcloud-db:3306 --timeout=120 && /entrypoint.sh apache2-foreground'
depends_on:
- nextcloud-db
Hello, i'm still struggling with this, Is there a way to auto-config a docker nextcloud instance sticking with sqlite (default database)? I tried to configure this instance through Travis CI yaml file here https://github.com/eblondel/ocs4R/blob/master/.travis.yml#L52 Thanks
By now, I guess the best option is to use wait-for-it, as suggested by @bhammack .
Thanks, I've finally resolved my issue, and to me it works well, including with a SQLITE database.
When installing with PostgreSQL/MySQL/MariaDB, nextcloud tries to use "oc_${NEXTCLOUD_ADMIN_USER}" as the database user, whether it's configured using environment variable or created on the webpage after installation.
Values set in docker-compose.yml are still being ignored and auto configuration does not work. I ran the db container separately prior to running all containers, as suggested by #593, which did not fix the problem.
Additionally, after setting NEXTCLOUD_TRUSTED_DOMAINS=mydomain in nextcloud's environment section of docker-compose, I'm still greeted by the untrusted domain error message. I remoted into a running container and was able to see that while docker is passing NEXTCLOUD_TRUSTED_DOMAINS correctly, config.php doesn't contain the domain.
Values set in
docker-compose.ymlare still being ignored and auto configuration does not work. I ran the db container separately prior to running all containers, as suggested by #593, which did not fix the problem.
Additionally, after settingNEXTCLOUD_TRUSTED_DOMAINS=mydomainin nextcloud's environment section of docker-compose, I'm still greeted by the untrusted domain error message. I remoted into a running container and was able to see that while docker is passingNEXTCLOUD_TRUSTED_DOMAINScorrectly,config.phpdoesn't contain the domain.
@jakkso I have the same issue here! Apparently it is a problem with the new release of the latest image, since a few days ago the environment variables were working normally
@krouw and anyone else having this problem: as a stopgap solution I copied config.php onto the host drive, mounted it as a volume, and hardcoded the needed values into it. If anyone else goes this route, be sure to adjust the permissions on config.php. I'm not a fan of hardcoding values, but I really just needed to get it running.
Most helpful comment
For anyone that's still struggling with this issue, I was able to come up with a solution in my docker-compose project. The cause of the issue has already been discussed above (mariadb takes ~60 seconds to setup on first launch, whereas nextcloud only performs 10 install attempts. If mariadb doesn't start up before nextcloud, the installation will fail and the parameters won't be applied)...
To resolve it, I mount the wait-for-it script found here https://github.com/vishnubob/wait-for-it into the container, override the entrypoint in my docker-compose file to call the script which then calls the entrypoint when the database container is accepting connections.