Skip to content

Instantly share code, notes, and snippets.

@jamct
Created April 18, 2024 08:16
Show Gist options
  • Save jamct/09514496da6263114b7ee4cd264ed8f7 to your computer and use it in GitHub Desktop.
Save jamct/09514496da6263114b7ee4cd264ed8f7 to your computer and use it in GitHub Desktop.
Docker-Compose for Paperless-ngx
# The UID and GID of the user used to run paperless in the container. Set this
# to your UID and GID on the host so that you have write access to the
# consumption directory.
USERMAP_UID=1028
USERMAP_GID=100
# Additional languages to install for text recognition, separated by a
# whitespace. Note that this is
# different from PAPERLESS_OCR_LANGUAGE (default=eng), which defines the
# language used for OCR.
# The container installs English, German, Italian, Spanish and French by
# default.
# See https://packages.debian.org/search?keywords=tesseract-ocr-&searchon=names&suite=buster
# for available languages.
PAPERLESS_OCR_LANGUAGES=deu
###############################################################################
# Paperless-specific settings
###############################################################################
# All settings defined in the paperless.conf.example can be used here. The
# Docker setup does not use the configuration file.
# A few commonly adjusted settings are provided below.
# This is required if you will be exposing Paperless-ngx on a public domain
# (if doing so please consider security measures such as reverse proxy)
#PAPERLESS_URL=https://paperless.example.com
# Adjust this key if you plan to make paperless available publicly. It should
# be a very long sequence of random characters. You don't need to remember it.
PAPERLESS_SECRET_KEY=123456789087654321_bitte_aendern!
# Use this variable to set a timezone for the Paperless Docker containers. If not specified, defaults to UTC.
PAPERLESS_TIME_ZONE=Europe/Berlin
# The default language to use for OCR. Set this to the language most of your
# documents are written in.
PAPERLESS_OCR_LANGUAGE=deu
# Set if accessing paperless via a domain subpath e.g. https://domain.com/PATHPREFIX and using a reverse-proxy like traefik or nginx
#PAPERLESS_FORCE_SCRIPT_NAME=/PATHPREFIX
#PAPERLESS_STATIC_URL=/PATHPREFIX/static/ # trailing slash required
#PAPERLESS_CONSUMER_POLLING=30
PAPERLESS_CONSUMER_ASN_BARCODE_PREFIX=ASN
PAPERLESS_CONSUMER_ENABLE_ASN_BARCODE=true
PAPERLESS_CONSUMER_ENABLE_BARCODES=true
PAPERLESS_CONSUMER_BARCODE_SCANNER=ZXING
version: "3.8"
services:
broker:
image: docker.io/library/redis:7
restart: unless-stopped
volumes:
- ./volumes/redis:/data
db:
image: docker.io/library/mariadb:10
restart: unless-stopped
volumes:
- ./volumes/database:/var/lib/mysql
environment:
MARIADB_HOST: paperless
MARIADB_DATABASE: paperless
MARIADB_USER: paperless
MARIADB_PASSWORD: paperless
MARIADB_ROOT_PASSWORD: paperless
webserver:
image: ghcr.io/paperless-ngx/paperless-ngx:latest
restart: unless-stopped
depends_on:
- db
- broker
ports:
- "8000:8000"
volumes:
- ./volumes/data:/usr/src/paperless/data
- ./volumes/media:/usr/src/paperless/media
- ./volumes/export:/usr/src/paperless/export
- ./incoming:/usr/src/paperless/consume
env_file: docker-compose.env
environment:
PAPERLESS_REDIS: redis://broker:6379
PAPERLESS_DBENGINE: mariadb
PAPERLESS_DBHOST: db
PAPERLESS_DBUSER: paperless
PAPERLESS_DBPASS: paperless
PAPERLESS_DBPORT: 3306
@heseber
Copy link

heseber commented Apr 25, 2024

This does not work on a Synology NAS with DSM 7.2.1-69057 Update 5 because the initialization of MariaDB fails due to permissions, see the log below:

paperless-db-1         | 2024-04-25 05:58:41+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.7+maria~ubu2204 started.
paperless-db-1         | 2024-04-25 05:58:43+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup/pu:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 8:cpuset:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 7:freezer:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 6:memory:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 5:blkio:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 4:cpuacct:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 3:devices:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 2:name=synomonitor:/system.slice/pkg-ContainerManager-dockerd.service
paperless-db-1         | 1:name=systemd:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a/memory.pressure not writable, functionality unavailable to MariaDB
paperless-db-1         | 2024-04-25 05:58:43+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
paperless-db-1         | 2024-04-25 05:58:43+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.7+maria~ubu2204 started.
paperless-db-1         | 2024-04-25 05:58:43+00:00 [Note] [Entrypoint]: Initializing database files
paperless-db-1         | 2024-04-25  5:58:44 0 [Warning] Can't create test file '/var/lib/mysql/96ca50903692.lower-test' (Errcode: 13 "Permission denied")
paperless-db-1         | /usr/sbin/mariadbd: Can't change dir to '/var/lib/mysql/' (Errcode: 13 "Permission denied")
paperless-db-1         |
paperless-db-1         | Installation of system tables failed!  Examine the logs in
paperless-db-1         | /var/lib/mysql/ for more information.
paperless-db-1         |
paperless-db-1         | The problem could be conflicting information in an external
paperless-db-1         | my.cnf files. You can ignore these by doing:
paperless-db-1         |
paperless-db-1         |     shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf
paperless-db-1         |
paperless-db-1         | You can also try to start the mariadbd daemon with:
paperless-db-1         |
paperless-db-1         |     shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
paperless-db-1         |
paperless-db-1         | and use the command line tool /usr/bin/mariadb
paperless-db-1         | to connect to the mysql database and look at the grant tables:
paperless-db-1         |
paperless-db-1         |     shell> /usr/bin/mariadb -u root mysql
paperless-db-1         |     MariaDB> show tables;
paperless-db-1         |
paperless-db-1         | Try '/usr/sbin/mariadbd --help' if you have problems with paths.  Using
paperless-db-1         | --general-log gives you a log in /var/lib/mysql/ that may be helpful.
paperless-db-1         | 2024-04-25  5:58:44 0 [ERROR] Aborting
paperless-db-1         |
paperless-db-1         | The latest information about mysql_install_db is available at
paperless-db-1         | https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
paperless-db-1         | You can find the latest source at https://downloads.mariadb.org and
paperless-db-1         | the maria-discuss email list at https://launchpad.net/~maria-discuss
paperless-db-1         |
paperless-db-1         | Please check all of the above before submitting a bug report
paperless-db-1         | at https://mariadb.org/jira
paperless-db-1         |
paperless-db-1         | 2024-04-25 05:59:00+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.7+maria~ubu2204 started.
paperless-db-1         | 2024-04-25 05:59:01+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup/pu:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 8:cpuset:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 7:freezer:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 6:memory:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 5:blkio:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 4:cpuacct:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 3:devices:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a
paperless-db-1         | 2:name=synomonitor:/system.slice/pkg-ContainerManager-dockerd.service
paperless-db-1         | 1:name=systemd:/docker/96ca5090369232c85e0ccf4271d2840cf7c050ab5218a4237fbcb601ca597f7a/memory.pressure not writable, functionality unavailable to MariaDB
paperless-db-1         | 2024-04-25 05:59:01+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
paperless-db-1         | 2024-04-25 05:59:01+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.11.7+maria~ubu2204 started.
paperless-db-1         | 2024-04-25 05:59:01+00:00 [Note] [Entrypoint]: Initializing database files
paperless-db-1         | 2024-04-25  5:59:01 0 [Warning] Can't create test file '/var/lib/mysql/96ca50903692.lower-test' (Errcode: 13 "Permission denied")
paperless-db-1         | /usr/sbin/mariadbd: Can't change dir to '/var/lib/mysql/' (Errcode: 13 "Permission denied")
paperless-db-1         | 2024-04-25  5:59:01 0 [ERROR] Aborting
paperless-db-1         |
paperless-db-1         | Installation of system tables failed!  Examine the logs in
paperless-db-1         | /var/lib/mysql/ for more information.
paperless-db-1         |
paperless-db-1         | The problem could be conflicting information in an external
paperless-db-1         | my.cnf files. You can ignore these by doing:
paperless-db-1         |
paperless-db-1         |     shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf
paperless-db-1         |
paperless-db-1         | You can also try to start the mariadbd daemon with:
paperless-db-1         |
paperless-db-1         |     shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
paperless-db-1         |
paperless-db-1         | and use the command line tool /usr/bin/mariadb
paperless-db-1         | to connect to the mysql database and look at the grant tables:
paperless-db-1         |
paperless-db-1         |     shell> /usr/bin/mariadb -u root mysql
paperless-db-1         |     MariaDB> show tables;
paperless-db-1         |
paperless-db-1         | Try '/usr/sbin/mariadbd --help' if you have problems with paths.  Using
paperless-db-1         | --general-log gives you a log in /var/lib/mysql/ that may be helpful.
paperless-db-1         |
paperless-db-1         | The latest information about mysql_install_db is available at
paperless-db-1         | https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
paperless-db-1         | You can find the latest source at https://downloads.mariadb.org and
paperless-db-1         | the maria-discuss email list at https://launchpad.net/~maria-discuss
paperless-db-1         |
paperless-db-1         | Please check all of the above before submitting a bug report
paperless-db-1         | at https://mariadb.org/jira
paperless-db-1         |

After docker-compose up -d the directory volumes/database has a new owner and group - owner with userid 999, and group synopkgs:

root@DiskStation:/volume1/paperless# ls -al volumes/database/
total 0
d---------+ 1     999 synopkgs  0 Apr 25 08:01 .

And a minor comment: the "./incoming" directory does not exist if one follows the instruction of the c't article. It should be changed to the real location of the "consume" folder on the host system.

@anderl1969
Copy link

I run into the same issue on my synology nas. Is there a solution for the wrong permssions?

@heseber
Copy link

heseber commented May 13, 2024

There seems to be an issue with MariaDB, use a different Docker yml file with Postgres instead, see https://github.com/paperless-ngx/paperless-ngx/tree/dev/docker/compose for options. If you understand German (which I guess you do if you read c't), see also my comment at https://www.heise.de/forum/c-t/Kommentare-zu-c-t-Artikeln/Papierloses-Buero-mit-paperless-ngx/Re-Anleitung-fuer-Synology-in-einigen-Teilen-verwirrend/posting-43929756/show/. I ended up mounting the media directory from the host system but all other volumes as Docker volumes. I made the media directory read-only for all users except the user paperless to avoid unintentional changes by normal users.

@holgi2705
Copy link

The webserver container exits with error code 159 when I start it with docker compose (mariadb and redis start up fine but I had to modify the docker compose a bit for that.

uname -a says:
Linux server01 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

my docker-compose.yml (webserver section only):

webserver:
image: ghcr.io/paperless-ngx/paperless-ngx:latest
platform: linux/arm64
restart: unless-stopped
depends_on:
- broker
- db
ports:
- "8001:8000"
volumes:
- ./data:/usr/src/paperless/data
- ./media:/usr/src/paperless/media
- ./export:/usr/src/paperless/export
- ./consume:/usr/src/paperless/consume
env_file: docker-compose.env
environment:
PAPERLESS_REDIS: redis://broker:6379
PAPERLESS_DBENGINE: mariadb
PAPERLESS_DBHOST: db
PAPERLESS_DBUSER: paperless
PAPERLESS_DBPASS: paperless
PAPERLESS_DBPORT: 3306

Any ideas to get it up and running??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment