How to set the permission of mounted directory when using docker #278

Open
opened 2022-06-07 11:45:49 +00:00 by duskmoon314 · 4 comments
duskmoon314 commented 2022-06-07 11:45:49 +00:00 (Migrated from gitlab.com)

Description

I'm trying to use Docker to deploy a server. And I have tried these two configurations:

volumes:
  - conduit:/var/lib/matrix-conduit

volumes:
  - "/data/conduit:/var/lib/matrix-conduit"

And I execute docker-compose as root, so the problem might have something to do with this.

warning: some trace filter directives would enable traces that are disabled statically
 | `info` would enable the INFO level for all targets
 = note: the static max level is `warn`
 = help: to enable INFO logging, remove the `max_level_warn` feature
The database couldn't be loaded or created. The following error occurred: There was a problem with the connection to the rocksdb database: IO error: While open directory: /var/lib/matrix-conduit: Permission denied

So I want to ask for help. How to correctly set the permission and deploy a server?

System Configuration

os: Linux 5.4.0-88-generic x86_64 GNU/Linux

Docker version 20.10.15

docker-compose version 1.29.2

docker-compose.yml:

conduit:
  image: matrixconduit/matrix-conduit:latest
  container_name: conduit
  restart: unless-stopped
  volumes:
    - "/data/conduit:/var/lib/matrix-conduit"
  networks:
    - traefik-net
  env_file:
    - .conduit.env
  labels:
    - "traefik.enable=true"
    - "traefik.http.routers.conduit.rule=Host(`matrix.$DOMAIN_NAME`)"
    - "traefik.http.routers.conduit.middlewares=cors-headers@docker"
    - "traefik.http.middlewares.cors-headers.headers.accessControlAllowOriginList=*"
    - "traefik.http.middlewares.cors-headers.headers.accessControlAllowHeaders=Origin, X-Requested-With, Content-Type, Accept, Authorization"
    - "traefik.http.middlewares.cors-headers.headers.accessControlAllowMethods=GET, POST, PUT, DELETE, OPTIONS"

.conduit.env:

CONDUIT_SERVER_NAME=matrix.mydomain.com
CONDUIT_DATABASE_PATH=/var/lib/matrix-conduit
CONDUIT_DATABASE_BACKEND=rocksdb
CONDUIT_PORT=6167
CONDUIT_MAX_REQUEST_SIZE=20000000 # in bytes, ~20 MB
CONDUIT_ALLOW_REGISTRATION='true'
CONDUIT_ALLOW_FEDERATION='true'
CONDUIT_TRUSTED_SERVERS='["matrix.org"]'
#CONDUIT_MAX_CONCURRENT_REQUESTS=100
#CONDUIT_LOG=info,rocket=off,_=off,sled=off
CONDUIT_ADDRESS=0.0.0.0
CONDUIT_CONFIG='' # Ignore this
<!-- If you're requesting a new feature, that isn't part of this project yet, then please consider filling out a "Feature Request" instead! If you need a hand setting up your conduit server, feel free to ask for help in the Conduit Matrix Chat: https://matrix.to/#/#conduit:fachschaften.org. --> ### Description I'm trying to use Docker to deploy a server. And I have tried these two configurations: ```YAML volumes: - conduit:/var/lib/matrix-conduit volumes: - "/data/conduit:/var/lib/matrix-conduit" ``` And I execute `docker-compose` as `root`, so the problem might have something to do with this. ``` warning: some trace filter directives would enable traces that are disabled statically | `info` would enable the INFO level for all targets = note: the static max level is `warn` = help: to enable INFO logging, remove the `max_level_warn` feature The database couldn't be loaded or created. The following error occurred: There was a problem with the connection to the rocksdb database: IO error: While open directory: /var/lib/matrix-conduit: Permission denied ``` So I want to ask for help. How to correctly set the permission and deploy a server? ### System Configuration <!-- Other data that might help us debug this issue, like os, conduit version, database backend --> os: Linux 5.4.0-88-generic x86_64 GNU/Linux Docker version 20.10.15 docker-compose version 1.29.2 docker-compose.yml: ```YAML conduit: image: matrixconduit/matrix-conduit:latest container_name: conduit restart: unless-stopped volumes: - "/data/conduit:/var/lib/matrix-conduit" networks: - traefik-net env_file: - .conduit.env labels: - "traefik.enable=true" - "traefik.http.routers.conduit.rule=Host(`matrix.$DOMAIN_NAME`)" - "traefik.http.routers.conduit.middlewares=cors-headers@docker" - "traefik.http.middlewares.cors-headers.headers.accessControlAllowOriginList=*" - "traefik.http.middlewares.cors-headers.headers.accessControlAllowHeaders=Origin, X-Requested-With, Content-Type, Accept, Authorization" - "traefik.http.middlewares.cors-headers.headers.accessControlAllowMethods=GET, POST, PUT, DELETE, OPTIONS" ``` .conduit.env: ``` CONDUIT_SERVER_NAME=matrix.mydomain.com CONDUIT_DATABASE_PATH=/var/lib/matrix-conduit CONDUIT_DATABASE_BACKEND=rocksdb CONDUIT_PORT=6167 CONDUIT_MAX_REQUEST_SIZE=20000000 # in bytes, ~20 MB CONDUIT_ALLOW_REGISTRATION='true' CONDUIT_ALLOW_FEDERATION='true' CONDUIT_TRUSTED_SERVERS='["matrix.org"]' #CONDUIT_MAX_CONCURRENT_REQUESTS=100 #CONDUIT_LOG=info,rocket=off,_=off,sled=off CONDUIT_ADDRESS=0.0.0.0 CONDUIT_CONFIG='' # Ignore this ```
George-Miao commented 2022-06-07 20:36:11 +00:00 (Migrated from gitlab.com)

Same problem here. Also tried SQLite, no luck.

the database couldn't be loaded or created. The following error occured: There was a problem with the connection to the sqlite database: unable to open database file: /data/conduit.db

Command:

docker run -it --rm \
    --mount type=volume,src=conduit-data,dst=/data \
    -e CONDUIT_SERVER_NAME=my.matrix.host \
    -e CONDUIT_DATABASE_BACKEND=sqlite \
    -e CONDUIT_DATABASE_PATH=/data\
    matrixconduit/matrix-conduit:next
Same problem here. Also tried SQLite, no luck. ``` the database couldn't be loaded or created. The following error occured: There was a problem with the connection to the sqlite database: unable to open database file: /data/conduit.db ``` Command: ``` docker run -it --rm \ --mount type=volume,src=conduit-data,dst=/data \ -e CONDUIT_SERVER_NAME=my.matrix.host \ -e CONDUIT_DATABASE_BACKEND=sqlite \ -e CONDUIT_DATABASE_PATH=/data\ matrixconduit/matrix-conduit:next ```
duskmoon314 commented 2022-06-11 11:46:37 +00:00 (Migrated from gitlab.com)

I find a not elegant way to solve this: chown -R 777 /data/conduit 😂

It seems the user in the docker is conduit(1000), but setting the user of /data/conduit to 1000 does not help. So I set it to 777 and it works.

I find a `not elegant` way to solve this: `chown -R 777 /data/conduit` 😂 It seems the user in the docker is `conduit(1000)`, but setting the user of `/data/conduit` to `1000` does not help. So I set it to 777 and it works.
scott.harper commented 2023-06-10 07:46:21 +00:00 (Migrated from gitlab.com)

More or less the same thing seems to work for me. Would love it if this could be worked out to not need "everyone read/write" on my folders 😓

More or less the same thing seems to work for me. Would love it if this could be worked out to not need "everyone read/write" on my folders :sweat:
zicklag commented 2024-02-02 00:00:42 +00:00 (Migrated from gitlab.com)

I've just deployed conduit with the docker container. I was able to do chown -R 1000:1000 /data/conduit.

It seems like @duskmoon314 wasn't able to do that above for some reason, but it worked for me.

Another possible workaround that weakens security would be to set the user of the container to root instead of the conduit user that it defaults to, but you shouldn't have to do that.

I've just deployed conduit with the docker container. I was able to do `chown -R 1000:1000 /data/conduit`. It seems like @duskmoon314 wasn't able to do that above for some reason, but it worked for me. Another possible workaround that weakens security would be to set the user of the container to `root` instead of the conduit user that it defaults to, but you shouldn't have to do that.
Sign in to join this conversation.
No labels
Android
CS::needs customer feedback
CS::needs follow up
CS::needs on prem installation
CS::waiting
Chrome
Design:: Ready
Design:: in progress
Design::UX
E2EE
Edge
Firefox
GDPR
Iteration 13 IM
Linux
MacOS
Need::Discussion
Need::Steps to reproduce
Need::Upstream fix
Needs:: Planning
Needs::Dev-Team
Needs::More information
Needs::Priority
Needs::Product
Needs::Refinement
Needs::Severity
Priority::1-Critical
Priority::2-Max
Priority::3-Impending
Priority::4-High
Priority::5-Medium
Priority::6-Low
Priority::7-None
Progress::Backlog
Progress::Review
Progress::Started
Progress::Testing
Progress::Triage
Progress::Waiting
Reporter::Sentry
Safari
Target::Community
Target::Customer
Target::Internal
Target::PoC
Target::Security
Team:Customer-Success
Team:Design
Team:Infrastructure
Team:Instant-Messaging
Team:Product
Team:Workflows
Type::Bug
Type::Design
Type::Documentation
Type::Feature
Type::Improvement
Type::Support
Type::Tests
Windows
blocked
blocked-by-spec
cla-signed
conduit
contribution::advanced
contribution::easy
contribution::help needed
from::review
iOS
p::ti-tenant
performance
product::triage
proposal
refactor
release-blocker
s: dart_openapi_codegen
s::Famedly-Patient
s::Org-Directory
s::Passport-Generator
s::Requeuest
s:CRM
s:Famedly-App
s:Famedly-Web
s:Fhiroxide
s:Fhiroxide-cli
s:Fhiroxide-client
s:Fhirs
s:Hedwig
s:LISA
s:Matrix-Dart-SDK
s:Role-Manager
s:Synapse
s:User-Directory
s:WFS-Matrix
s:Workflow Engine
s:dtls
s:famedly-error
s:fcm-shared-isolate
s:matrix-api-lite
s:multiple-tab-detector
s:native-imaging
severity::1
severity::2
severity::3
severity::4
technical-debt
voip
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Matthias/conduit#278
No description provided.