neo4j / docker-neo4j

Docker Images for the Neo4j Graph Database
Apache License 2.0
331 stars 172 forks source link

chown: changing ownership of '/var/lib/neo4j/conf/neo4j.conf': Read-only file system #441

Closed robertluoxu closed 2 months ago

robertluoxu commented 1 year ago

Guidelines

version: neo4j:4.4.7 docker: Docker version 20.10.21

  spec:
      containers:
        - image: neo4j:4.4.7
          imagePullPolicy: IfNotPresent
          name: container-0
          securityContext:
            allowPrivilegeEscalation: true
            privileged: false
            readOnlyRootFilesystem: false
            capabilities: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /var/lib/neo4j/data
              name: vol-wpgyk
            - mountPath: /var/lib/neo4j/conf
              name: vol-nlmes
          __active: true

logs :

chown: changing ownership of '/var/lib/neo4j/conf/..2023_05_06_06_51_54.97930143/neo4j.conf': Read-only file system Sat, May 6 2023 2:53:38 pm | chown: changing ownership of '/var/lib/neo4j/conf/..2023_05_06_06_51_54.97930143': Read-only file system Sat, May 6 2023 2:53:38 pm | chown: changing ownership of '/var/lib/neo4j/conf/..data': Read-only file system Sat, May 6 2023 2:53:38 pm | chown: changing ownership of '/var/lib/neo4j/conf/neo4j.conf': Read-only file system Sat, May 6 2023 2:53:38 pm | chown: changing ownership of '/var/lib/neo4j/conf': Read-only file system

jennyowen commented 1 year ago

ok so is this an actual error or just a warning? Does it fail to start?

The data volume should be mounted to /data not /var/lib/neo4j/data and the conf volume should be mounted to /conf not /var/lib/neo4j/conf

arikkfir commented 2 months ago

Same thing happens for the import folder:

chown: changing ownership of '/var/lib/neo4j/import/01-clean-database.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..data': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..2024_07_22_09_10_58.3593008703/01-clean-database.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..2024_07_22_09_10_58.3593008703/02-create-acme-tenant.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..2024_07_22_09_10_58.3593008703': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/02-create-acme-tenant.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/01-clean-database.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..data': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..2024_07_22_09_10_58.3593008703/01-clean-database.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..2024_07_22_09_10_58.3593008703/02-create-acme-tenant.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/..2024_07_22_09_10_58.3593008703': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import/02-create-acme-tenant.cypher': Read-only file system
chown: changing ownership of '/var/lib/neo4j/import': Read-only file system                                                                                           

In this case, I've mounted the /var/lib/neo4j/import folder like so:

apiVersion: apps/v1
kind: Deployment
...
spec:
  containers:
    - image: ...
      ...
      volumeMounts:
        - mountPath: /var/lib/neo4j/import/
          name: init-scripts
      ...
  volumes:
    - configMap:
        defaultMode: 420
        name: init-scripts
        optional: false
      name: init-scripts
  ...

So essentially, since the import mount is from a ConfigMap, it is read-only, and thus Neo4j fails to chown it - is there a way to disable the chown behavior for such use-cases?

jennyowen commented 2 months ago

@arikkfir there is no way to disable the chown behaviour. The neo4j user inside the container needs to be able to read and write to all folders and files under /var/lib/neo4j. I do not recommend mounting anything under /var/lib/neo4j for this reason.

For imports, you can mount your folder to /import. This will still be visible to neo4j but will not be chowned. The relevant documentation is here: https://neo4j.com/docs/operations-manual/current/docker/mounting-volumes/#docker-volumes-mount-points