Skip to content

Mounted volumes are owned by root #4620

@kromsam

Description

@kromsam

Describe the bug
When making the Etherpad container, I created a volume to make sure data is persisted. The problem is that the folders that are made for the container, are owned by root. This means that the container, which is run by user etherpad, cannot access this directory.

This led to an issue like this: #4598

To Reproduce
This is my docker-compose file.

version: '2.2'
services:

# Let's Encrypt
  letsencrypt:
    container_name: letsencrypt
    image: linuxserver/swag
    restart: always
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - URL=${TLD}
      - SUBDOMAINS=${SUBS}
      - EXTRA_DOMAINS=${EXTRADOM}
      - VALIDATION=http
      - EMAIL=${MAILADRES}
    volumes:
      - ${APPDATA}/Letsencrypt:/config
    networks:
      - etherpad_net
    ports:
      - 443:443
      - 80:80
    cap_add:
      - NET_ADMIN

# Etherpad
  etherpad:
    container_name: etherpad
    image: etherpad/etherpad
    restart: always
    volumes:
      - ${APPDATA}/Etherpad:/opt/etherpad-lite/var
    environment:
      - DB_TYPE=postgres
      - DB_HOST=etherpad_db
      - DB_PORT=5432
      - DB_NAME=${EPDB_NAME}
      - DB_USER=${EPDB_USER}
      - DB_PASS=${EPDB_PASS}
      - ADMIN_PASSWORD=${EPDB_ADMIN}
    networks:
      - etherpad_net      
  postgres:
    container_name: etherpad_db
    image: postgres
    restart: always
    environment:
      - POSTGRES_DB=${EPDB_NAME}
      - POSTGRES_USER=${EPDB_USER}
      - POSTGRES_PASSWORD=${EPDB_PASS}
    volumes:
     - ${APPDATA}/Etherpad_DB:/var/lib/postgresql/data
    networks:
      - etherpad_net
    
networks:
  etherpad_net:
    driver: bridge

Additional context
This is the situation inside the container. As you can see, the mounted /var folder is owned by root.

$ ls -l
total 624
-rw-r--r-- 1 etherpad etherpad     64 Dec 21 15:17 APIKEY.txt
-rw-rw-r-- 1 etherpad root      36008 Dec 20 23:35 CHANGELOG.md
-rw-rw-r-- 1 etherpad root       8217 Dec 20 23:35 CONTRIBUTING.md
-rw-rw-r-- 1 etherpad root      11353 Dec 20 23:35 LICENSE
-rw-rw-r-- 1 etherpad root        837 Dec 20 23:35 Makefile
-rw-rw-r-- 1 etherpad root       8202 Dec 20 23:35 README.md
-rw-rw-r-- 1 etherpad root        118 Dec 20 23:35 SECURITY.md
-rw-r--r-- 1 etherpad etherpad     64 Dec 21 15:17 SESSIONKEY.txt
drwxrwxr-x 1 etherpad root       4096 Dec 20 23:35 bin
drwxrwxr-x 1 etherpad root       4096 Dec 20 23:35 doc
drwxrwxr-x 1 etherpad root       4096 Dec 20 23:35 node_modules
-rw-rw-r-- 1 etherpad root     453622 Dec 20 23:35 package-lock.json
-rw-rw-r-- 1 etherpad root       2312 Dec 20 23:35 package.json
-rw-rw-r-- 1 etherpad root      20033 Dec 20 23:35 settings.json
-rw-rw-r-- 1 etherpad root      20033 Dec 20 23:35 settings.json.docker
-rw-rw-r-- 1 etherpad root      18686 Dec 20 23:35 settings.json.template
drwxrwxr-x 1 etherpad root       4096 Dec 21 15:17 src
-rw-rw-r-- 1 etherpad root         51 Dec 20 23:35 start.bat
drwxrwxr-x 1 etherpad root       4096 Dec 20 23:35 tests
drwxr-xr-x 2 root     root       4096 Dec 21 15:17 var

This comment #3674 (comment) by @pierreprinetti seems to hint at what is happening here.

I am using 5001 this time (totally made up). Unfortunately, this means that we again introduce annoyance to volume users.

It also seems to be a Docker-wide problem: moby/moby#2259 . Although most containers I use (the LinuxServer ones for instance: https://github.com/linuxserver) don't seem to have this problem. So there must be a solution for this issue. LinuxServer uses ENV variables that let's users map PUID and PGID of the host user and container user.

In this example I only mounted /opt/etherpad-live/var. But I think I would prefer to be able to mount /opt/etherpad-lite, so that settings also will be persistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dockerwontfixWont Fix these things, no hate.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions