Paperless-ngx: Docker-compose file reddit / selfhosted ---------------------------------------------------------------------- sauladal · 2023-11-09 00:48 I'm going to set-up paperless-ngx but I'm struggling to fully understand the instructions for the docker-compose.yaml file (I'm new to docker-compose). Namely it's which volumes should be mapped and which don't need to be renamed. I'm setting this up on a Synology with 7.2 using Container Manager. So following instructions from [here](https://docs.paperless- ngx.com/setup/#docker_hub) and using [docker-compose.postgres- tika.yml](https://github.com/paperless-ngx/paperless- ngx/blob/main/docker/compose/docker-compose.postgres-tika.yml): # docker-compose file for running paperless from the docker container registry. # This file contains everything paperless needs to run. # Paperless supports amd64, arm and arm64 hardware. # # All compose files of paperless configure paperless in the following way: # # - Paperless is (re)started on system boot, if it was running before shutdown. # - Docker volumes for storing data are managed by Docker. # - Folders for importing and exporting files are created in the same directory # as this file and mounted to the correct folders inside the container. # - Paperless listens on port 8000. # # In addition to that, this docker-compose file adds the following optional # configurations: # # - Instead of SQLite (default), PostgreSQL is used as the database server. # - Apache Tika and Gotenberg servers are started with paperless and paperless # is configured to use these services. These provide support for consuming # Office documents (Word, Excel, Power Point and their LibreOffice counter- # parts. # # To install and update paperless with this file, do the following: # # - Copy this file as 'docker-compose.yml' and the files 'docker- compose.env' # and '.env' into a folder. # - Run 'docker-compose pull'. # - Run 'docker-compose run --rm webserver createsuperuser' to create a user. # - Run 'docker-compose up -d'. # # For more extensive installation and update instructions, refer to the # documentation. version: "3.4" services: broker: image: docker.io/library/redis:7 restart: unless-stopped volumes: - redisdata:/data db: image: docker.io/library/postgres:15 restart: unless-stopped volumes: - pgdata:/var/lib/postgresql/data environment: POSTGRES_DB: paperless POSTGRES_USER: paperless POSTGRES_PASSWORD: paperless webserver: image: ghcr.io/paperless-ngx/paperless-ngx:latest user: 1029 restart: unless-stopped depends_on: - db - broker - gotenberg - tika ports: - "8010:8000" healthcheck: test: ["CMD", "curl", "-fs", "-S", "--max-time", "2", "http://localhost:8000"] interval: 30s timeout: 10s retries: 5 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_DBHOST: db PAPERLESS_TIKA_ENABLED: 1 PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000 PAPERLESS_TIKA_ENDPOINT: http://tika:9998 gotenberg: image: docker.io/gotenberg/gotenberg:7.8 restart: unless-stopped # The gotenberg chromium route is used to convert .eml files. We do not # want to allow external content like tracking pixels or even javascript. command: - "gotenberg" - "--chromium-disable-javascript=true" - "--chromium-allow-list=file:///tmp/.*" tika: image: ghcr.io/paperless-ngx/tika:latest restart: unless-stopped volumes: data: media: pgdata: redisdata: Only changes I made so far above were a port change and adding a user id into webserver. For the volumes, the instructions only mention mapping the consume folder, but don't all of them need to be mapped in order to not get deleted with updates? So "./consume:/usr/src/paperless/consume" needs to be "/volume1/docker/paperless/consume:/usr/src/paperless/consume" - right? But what about: volumes: - redisdata:/data volumes: - pgdata:/var/lib/postgresql/data volumes: - data:/usr/src/paperless/data - media:/usr/src/paperless/media - ./export:/usr/src/paperless/export Do all of those need to be changed? I assume yes and probably to just add "/volume1/docker/paperless/" to the start of each. Right? But most importantly, I don't fully understand the top-level volumes element and how that comes into play or needs to be modified (from the bottom of the config): volumes: data: media: pgdata: redisdata: Hopefully someone can help or point me to where I can get this answered. Thank you! ---------------------------------------------------------------------- thekrautboy · 2023-11-09 01:20 Learn about the difference between Docker volumes as bind mounts and as named volumes. In that compose the volumes for redis, postgres, media and data are created in a different way as you can see, they are named volumes, they are created and managed by Docker, typically stored in a specific path on the host. The advantage is that you dont need to worry about creating the folders and setting correct permissions. The consumw folder is created as a bind mount volume, where you decide where exactly on the Docker host you want to map it to, the left part of `./consume:/usr/src/paperless/consume` and the advantage here is that you can freely pick where that should be. But you need to take care of permissions. The same for the export volume. You probably dont need to change the named volumes, and for the bind mounts you simply pick wherever you want them to be. Why not ask /r/Docker and /r/Synology. ---------------------------------------------------------------------- sauladal · 2023-11-09 01:27 Hey thank you for your response! I did notice the two different types of volumes. I guess I'm more familiar with bind mounts and less familiar with named volumes. And with the named volumes comes the top-level volumes element as I mentioned in OP but [referenced here](https://docs.docker.com/compose/compose-file/07-volumes/). I asked here because it appears many people on this subreddit are very familiar with setting up paperless-ngx. Likely almost everyone using docker and probably at least some on Synology. But I can give those subreddits a shot too if it doesn't pan out. So just to understand, with the named volumes, since they're taken care of by Docker and not on my front facing path, aren't they prone to deletion with updates/reinstalls of containers (or less portability if changing to a new server etc)? Similar to not binding a volume at all? ---------------------------------------------------------------------- thekrautboy · 2023-11-09 01:38 No they are just paths on your host, when created like the above they are persistent and dont get removed when the container is stopped or updated. When moving them to another host you simply need to find them in the path where your Docker setup has created them and copy the data. A bit more effort than just using bind mounts. Choice is yours. ---------------------------------------------------------------------- sauladal · 2023-11-09 01:45 So I can just replace them all with bind mounts on each line and then remove the entire volumes section volumes: data: media: pgdata: redisdata: at the bottom of the yaml? ---------------------------------------------------------------------- thekrautboy · 2023-11-09 01:50 If you want to, yes. ---------------------------------------------------------------------- sauladal · 2023-11-09 02:59 Thanks for your help! ---------------------------------------------------------------------- human_with_humanity · 2023-11-12 19:34 i also tried to run paperless ngx with below script `services:` `broker:` `image: "docker.io/library/redis:7"` `volumes:` `- /mnt/local/Data_NAS/docker/docker_configs/paperless_ngx/redisdata:/ data` `restart: unless-stopped` `webserver:` `image: "ghcr.io/paperless-ngx/paperless-ngx:latest"` `container_name: "paperless-ngx"` `user: "1000"` `depends_on:` `- broker` `- gotenberg` `- tika` `ports:` `- "8000:8000"` `healthcheck:` `test: ["CMD", "curl", "-fs", "-S", "--max-time", "2", "http://localhost:8000"]` `interval: 30s` `timeout: 10s` `retries: 5` `volumes:` `- /mnt/local/Data_NAS/docker/docker_configs/paperless_ngx/data:/usr/s rc/paperless/data` `- /mnt/local/Data_NAS/docker/docker_configs/paperless_ngx/media:/usr/ src/paperless/media` `- /mnt/local/Data_NAS/docker/docker_configs/paperless_ngx/export:/usr /src/paperless/export` `- /mnt/local/Data_NAS/docker/docker_configs/paperless_ngx/consume:/us r/src/paperless/consume` `env_file: docker-compose.env` `environment:` `PAPERLESS_REDIS: redis://broker:6379` `PAPERLESS_TIKA_ENABLED: 1` `PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000` `PAPERLESS_TIKA_ENDPOINT: http://tika:9998` `restart: unless-stopped` `gotenberg:` `image: "docker.io/gotenberg/gotenberg:7.8"` `restart: unless-stopped` `# The gotenberg chromium route is used to convert .eml files. We do not` `# want to allow external content like tracking pixels or even javascript.` `command:` `- "gotenberg"` `- "--chromium-disable-javascript=true"` `- "--chromium-allow-list=file:///tmp/.*"` `tika:` `image: "ghcr.io/paperless-ngx/tika:latest"` `restart: unless-stopped` but when i run "docker compose run --rm webserver createsuperuser" after pulling the images it give error `[+] Creating 3/0` `✔ Container paperless-tika-1 Running 0.0s` `✔ Container paperless-gotenberg-1 Running 0.0s` `✔ Container paperless-broker-1 Running 0.0s` `Paperless-ngx docker container starting...` `Installing languages...` `Reading package lists... Done` `E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)` ​ the docker compose.env file is as below `# 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=1000` `USERMAP_GID=1000` `# 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=tur ces hin` `##################################################################### ##########` `# 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=change-me` `# Use this variable to set a timezone for the Paperless Docker containers. If not specified, defaults to UTC.` `PAPERLESS_TIME_ZONE=Asia/Kolkata` `# The default language to use for OCR. Set this to the language most of your` `# documents are written in.` `#PAPERLESS_OCR_LANGUAGE=eng` `# 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` ​ what is the reason for this? how to fix it?