How to read/write a file from Docker Image and how to open the docker logs

Hi everyone,

I’m currently building a new Workflow that is downloading a file from an SFTP, Decoding the file, and reading it as binary.

The decoded file has two CSVs inside and I want to process them differently so I added an if afterward and then want to read the file as binary or spreadsheet but none works.

I got two errors:
The first was that I got disconnected from n8n and sudo docker container ls showed, that the status time was reset so it seems the docker image restarted :sweat_smile:. But fetching the logs seems impossible as I get OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: “bash”: executable file not found in $PATH: unknown

The second problem is due to the docker image I guess as the binary node is stating ERROR: The file could not be found

the workflow looks like this

the binary node in the end is

{
“nodes”: [
{
“parameters”: {
“filePath”: “={{$binary.file_KCI0.fileName}}”
},
“name”: “Read Binary File”,
“type”: “n8n-nodes-base.readBinaryFile”,
“typeVersion”: 1,
“position”: [
1060,
60
]
}
],
“connections”: {}
}

Could you tell me if it’s possible to open files from inside the docker image? I did not find any configuration for it and I’m unfortunately not very familiar with docker.

Nevertheless i checked some postings and i found the container

4d0f0349784f n8nio/n8n “tini – /docker-ent…” 3 weeks ago Up 16 minutes 127.0.0.1:6789->5678/tcp n8n_n8n_

But I seem unable to access the logs with
sudo docker logs --timestamps --since 2022-03-02T15:00:00Z n8n

Thank you very much and have a great evening

Information on your n8n setup

  • 0.161.1
  • Postgres DB
  • N8n runs in Docker

sudo docker logs --timestamps --since 2022-03-02T15:00:00Z n8n

Hey @Benjamin_Exner, it seems your docker container has a different than n8n. From the output you have shared it seems the name would be n8n_n8n_ instead. So the logs command would be docker logs n8n_n8n_ instead of docker logs n8n (plus any options you might want to use). Alternatively, you can also use the container ID as an identifier, so docker logs 4d0f0349784f based on your output.

Reading files when running n8n via docker is possible, you’d only need to make sure the file is accessible to the docker container. For example, if you are running n8n via docker compose, you’d need to add a new volume to the respective docker compose file like so:

version: '3.1'

services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - 5678:5678
    links:
      - postgres
    volumes:
      - C:\Users\Tom\n8n\n8n_data:/home/node/.n8n
      - C:\Users\Tom\Desktop:/home/node/Desktop

In this example, the folder C:\Users\Tom\n8n\n8n_data would be available inside the docker container as /home/node/.n8n and C:\Users\Tom\Desktop would be seen by the container as /home/node/Desktop.

This would be the equivalent to the -v option when using the docker run command instead of docker compose.

1 Like

Hi @MutedJam ,

oh stupid me, I tried all kinds of naming but I did not think about using the “NAME” as I was able to access Postgres differently.

I was able to check the logs but did not see anything strange so I will raise the log level and if it persists I now know where to look for :wink: .

I understood what to do regarding docker-compose and will add a Volume (always happy to learn something new :slight_smile: ).

Thank you so much, the question is solved and I wish you a great day

BR
Benji

1 Like