Read File from disk in docker mode issue

Describe the problem/error/question

Hi, as too many people I encountered difficulties when trying to open a file from my disk.

N8N is running on my computer in a Docker Compose instance (under windows OS)

I have mounted a volume (named /localhome) in my docker instance to share files with my computer

When trying to open a csv from this directory with the Read/Files node it fails.

However I can write a file and even by using the same path, it fails to open the file previously created:

here the docker files view with 2 files: file.csv which is the one previously created by N8N, and hky_export which the imported file from windows

I assume some path format but I cannot find which one (and don’t understand why it works for write and not for read…)

I have tried different version of the path (notably by changing / to \ and multiple combination of them) but with no results:

//localhome/file.csv

\\localhome\file.csv

/\localhome/file.csv

//\localhome/file.csv

\localhome\file.csv

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "a481ff2d-f217-4565-b7ed-39151e7f7aaf",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "fileSelector": "/\\localhome/file.csv",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        864,
        0
      ],
      "id": "9ed40f09-a8c1-41ab-9aa9-355d1e8f32dc",
      "name": "Read/Write Files from Disk",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "/\\localhome/file.csv",
        "options": {
          "append": false
        }
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        656,
        0
      ],
      "id": "dc465d1c-8674-4714-8234-ef458840647f",
      "name": "Read/Write Files from Disk1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "eed205e0-2ae3-4fbd-a404-4562fd12d9c9",
              "name": "test",
              "value": "derr",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        208,
        0
      ],
      "id": "61f59f6c-dbfa-4600-9b0a-97aa48b9191d",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        416,
        0
      ],
      "id": "b9b4142c-b29c-4c22-bf27-cc8494ffdbb0",
      "name": "Convert to File"
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read/Write Files from Disk": {
      "main": [
        []
      ]
    },
    "Read/Write Files from Disk1": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f0e566769232b80e9c7a3b41cbab25fa3443c53f9808747f8717f82aca36fad0"
  }
}

Share the output returned by the last node

setup

  • n8n version: 1.109.2
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker (via docker compose underwiindows)
  • Operating system: windows 11

hello @Viper95 welcome to the :n8n: community,

The best thing to do is add an Execute Command node with the command pwd to check the directory.
After that, you can use it accordingly.

Try this out and let me know if it works:

Hey @Viper95
Is there a reason you have an actual backslash in the name of your folder?

1 Like

cannot say it appears when I have mounted the volume via the docker compose UI. Will check if I can avoid it

I have restart a container and now the localhome appears without the \

Maybe a mistake from me when I set the previous one

Good job, seems it works now.

I cannot say why it was working for writing and not for reading

Now I need to check how to use the data correctly in the next nodes (seems weird as well)

Thanks and see you

1 Like

Thanks for the tips but I don’t know exactly what to do with it (return local/node)

Solutions have been find anyway.

Thanks again

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.