crazy-max / docker-nextcloud

Nextcloud Docker image
MIT License
245 stars 47 forks source link

Direct access to the database (set up from docker compose example) #8

Closed enchained closed 5 years ago

enchained commented 5 years ago

I need direct access to the database to fix timestamps after a scan, but noticed that the usual place is empty:

docker exec -it -u root compose_mariadb_1 sh
# mysql -u nextcloud -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.2.20-MariaDB-1:10.2.20+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| nextcloud          |
+--------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> use nextcloud
Database changed
MariaDB [nextcloud]> show tables;
Empty set (0.01 sec)

MariaDB [nextcloud]>

my docker-compose is same as example regarding the database:

 mariadb:
    image: mariadb:10.2
    volumes:
      - "db:/var/lib/mysql"
    environment:
      - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
      - "MYSQL_DATABASE=nextcloud"
      - "MYSQL_USER=nextcloud"
      - "MYSQL_PASSWORD=****"
    restart: always

nextcloud.env:

DB_TYPE=mysql
DB_HOST=db
DB_NAME=nextcloud
DB_USER=nextcloud
DB_PASSWORD=****

Any way I can access it to perform the UPDATE action on a table?

enchained commented 5 years ago

I noticed that if on the web I go to Administration - Monitoring (settings/admin/serverinfo), it says: Database Type: sqlite3 Version: 3.24.0 Size: 4.1 MB

Should it be that way with my env vars? And where to look for that sqlite3 db instead?

crazy-max commented 5 years ago

@enchained Can you post your docker-compose file please, your host OS (Debian 9 for example) and tell me if it's a first/clean install.

enchained commented 4 years ago

@crazy-max Hi. Back then I decided to continue using sqlite db instead, but currently I'm experiencing performance issues on webdav, and decided to either convert the db as a temp solution, or do a clean install of a new nextcloud version when I'll find the time. However now I am afraid that if I'm going to setup reusing my old compose, I'll end up with sqlite once more. Could you please tell me what was possibly wrong with my old compose file, what could cause defaulting to an sqlite db?

It was a first install. Host os is Arch Linux, Kernel: Linux 4.19.4-arch1-1-ARCH.

cat docker-compose.yml

version: "3.2"

services:
  traefik:
    image: traefik:1.6-alpine
    command:
      - "--logLevel=INFO"
      - "--defaultentrypoints=http,https"
      - "--entryPoints=Name:http Address::80 Redirect.EntryPoint:https"
      - "--entryPoints=Name:https Address::443 TLS"
      - "--docker"
      - "--docker.exposedbydefault=false"
      - "--docker.domain=mydomain.com"
      - "--acme=false"
      - "--acme.acmelogging=true"
      - "--acme.email=myemail@gmail.com"
      - "--acme.storage=acme.json"
      - "--acme.entryPoint=https"
      - "--acme.onhostrule=true"
      - "--acme.httpchallenge=true"
      - "--acme.httpchallenge.entrypoint=http"
      - "--api"
    ports:
      - target: 80
        published: 80
        protocol: tcp
      - target: 443
        published: 443
        protocol: tcp
      - target: 8080
        published: 8080
        protocol: tcp
    volumes:
      - "./acme.json:/acme.json"
      - "/var/run/docker.sock:/var/run/docker.sock"
    restart: always

  db:
    image: mariadb:10.2
    volumes:
      - "db:/var/lib/mysql"
    environment:
      - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
      - "MYSQL_DATABASE=nextcloud"
      - "MYSQL_USER=nextcloud"
      - "MYSQL_PASSWORD=****"
    restart: always

  redis:
    image: redis:4.0-alpine
    restart: always

  nextcloud:
    image: crazymax/nextcloud:latest
    depends_on:
      - db
      - redis
    volumes:
      - "/data/docker/nextcloud-crazy-max:/data"
      - "/data:/ext-data"
      - "/data/docker/nextcloud-crazy-max/nginx.conf:/etc/nginx/nginx.conf:ro"
    labels:
      - "traefik.enable=true"
      - "traefik.backend=nextcloud"
      - "traefik.port=80"
      - "traefik.frontend.redirect.regex=^(.*)/nextcloud$$"
      - "traefik.frontend.redirect.replacement=$$1/nextcloud/"
      - "traefik.frontend.rule=Host: mydomain.com; PathPrefix: /nextcloud; ReplacePathRegex: ^/nextcloud/(.*) /$$1"
    env_file:
      - "./nextcloud.env"
    restart: always

  cron:
    image: crazymax/nextcloud:latest
    depends_on:
      - nextcloud
    volumes:
      - "/data/docker/nextcloud-crazy-max:/data"
    command: "/usr/local/bin/cron"
    env_file:
      - "./nextcloud.env"
    environment:
      - "CRON_PERIOD=*/10 * * * *"
    restart: always

volumes:
  db:

cat nextcloud.env

TZ=Europe/Berlin

MEMORY_LIMIT=512M
UPLOAD_MAX_SIZE=20G
OPCACHE_MEM_SIZE=128
APC_SHM_SIZE=128M

HSTS_HEADER=max-age=0; includeSubDomains
RP_HEADER=strict-origin

DB_TYPE=mysql
DB_HOST=db
DB_NAME=nextcloud
DB_USER=nextcloud
DB_PASSWORD=****

And another question: I noticed that you've added a SUBDIR var later here https://github.com/crazy-max/docker-nextcloud/issues/7 while I was still using modifications suggested by @Numline1. Does starting using SUBDIR= in nextcloud.env means I would no longer need to modify nginx.conf location $schemes myself and mounting that as a volume in compose anymore?