docker - MariaDB Docker 容器 - 权限被拒绝 - 没有对目录的访问权限
问题描述
我正在尝试让 PhotoPrism 在我的 Ubuntu 20.04 服务器上的 Docker 中工作。
Photoprism 尝试为数据库启动 MariaDB 容器,但我似乎不断收到错误,这似乎指向权限问题。我已经粘贴了下面的错误消息。
mariadb_1 | 2021-10-25 10:15:08+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.4+maria~focal started.
mariadb_1 | 2021-10-25 10:15:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mariadb_1 | 2021-10-25 10:15:08+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.4+maria~focal started.
mariadb_1 | 2021-10-25 10:15:09+00:00 [Note] [Entrypoint]: Initializing database files
mariadb_1 | 2021-10-25 10:15:09 0 [Warning] Can't create test file /var/lib/mysql/7b47dce774fc.lower-test
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] mariadbd: Can't create/write to file '/var/lib/mysql/aria_log_control' (Errcode: 13 "Permission denied")
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] mariadbd: Got error 'Can't create file' when trying to use aria control file '/var/lib/mysql/aria_log_control'
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] Plugin 'Aria' init function returned error.
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] InnoDB: The error means mariadbd does not have the access rights to the directory.
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] InnoDB: The error means mariadbd does not have the access rights to the directory.
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] InnoDB: Cannot open datafile './ibdata1'
mariadb_1 | 2021-10-25 10:15:09 0 [ERROR] InnoDB: Could not open or create the system tablespace.
我尝试更改所有相关文件夹的文件权限,但似乎没有任何效果。我已经检查过 LinuxSE 没有处于活动状态,并且 AppArmor 似乎没有创建任何日志消息,所以这似乎不是原因。
我不知道我能解决这个问题。存储卷是安装在 Windows 10 机器上的网络共享。不确定是否是导致问题的原因?任何帮助将不胜感激 - 这让我发疯!
我的 docker-compose 文件如下:
version: '3.5'
services:
photoprism:
image: photoprism/photoprism:latest
depends_on:
- mariadb
security_opt:
- seccomp:unconfined
- apparmor:unconfined
ports:
- "2342:2342" # [server]:[container]
environment:
PHOTOPRISM_ADMIN_PASSWORD: "[REDACTED]" # PLEASE CHANGE: Your initial admin password (min 4 characters)
PHOTOPRISM_SITE_URL: "http://localhost:2342/" # Public URL incl http:// or https:// and /path, :port is optional
PHOTOPRISM_ORIGINALS_LIMIT: 5000 # File size limit for originals in MB (increase for high-res video)
PHOTOPRISM_HTTP_COMPRESSION: "gzip" # Improves transfer speed and bandwidth utilization (none or gzip)
PHOTOPRISM_DEBUG: "false" # Run in debug mode (shows additional log messages)
PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection)
PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality)
PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features
PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup
PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server
PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI
PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow
PHOTOPRISM_DISABLE_FACES: "false" # Disables facial recognition
PHOTOPRISM_DISABLE_CLASSIFICATION: "false" # Disables image classification
PHOTOPRISM_DARKTABLE_PRESETS: "false" # Enables Darktable presets and disables concurrent RAW conversion
PHOTOPRISM_DETECT_NSFW: "false" # Flag photos as private that MAY be offensive (requires TensorFlow)
PHOTOPRISM_UPLOAD_NSFW: "true" # Allow uploads that MAY be offensive
PHOTOPRISM_DATABASE_DRIVER: "mysql" # Use MariaDB 10.5+ or MySQL 8+ instead of SQLite for improved performance
PHOTOPRISM_DATABASE_SERVER: "mariadb:3306" # MariaDB or MySQL database server (hostname:port)
PHOTOPRISM_DATABASE_NAME: "photoprism" # MariaDB or MySQL database schema name
PHOTOPRISM_DATABASE_USER: "photoprism" # MariaDB or MySQL database user name
PHOTOPRISM_DATABASE_PASSWORD: "[REDACTED]" # MariaDB or MySQL database user password
PHOTOPRISM_SITE_TITLE: "PhotoPrism"
PHOTOPRISM_SITE_CAPTION: "Browse Your Life"
PHOTOPRISM_SITE_DESCRIPTION: ""
PHOTOPRISM_SITE_AUTHOR: ""
HOME: "/photoprism"
working_dir: "/photoprism"
volumes:
- "/media/m/Photos:/photoprism/originals"
- "/media/u/Docker/photoprism2:/photoprism/storage"
mariadb:
restart: unless-stopped
image: mariadb:10.6
security_opt:
- seccomp:unconfined
- apparmor:unconfined
command: mysqld --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=120
volumes:
- "/media/u/Docker/photoprism2/database:/var/lib/mysql" # Never remove
environment:
MYSQL_ROOT_PASSWORD: [REDACTED]
MYSQL_DATABASE: photoprism
MYSQL_USER: photoprism
MYSQL_PASSWORD: [REDACTED]
watchtower:
restart: unless-stopped
image: containrrr/watchtower
environment:
WATCHTOWER_CLEANUP: "true"
WATCHTOWER_POLL_INTERVAL: 7200 # Checks for updates every two hours
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
# - "~/.docker/config.json:/config.json" # Optional, for authentication if you have a Docker Hub account