Multicontainer project - Created a csv file inside a container, how to read it from another one?

Hello everyone,

I am running balena os on a raspberry pi with a docker-compose.yml file. More specifically i have a container which initializes spi communication with an adc, reads data and then stores them in a csv file. Then i have a second container which runs node-red and exposes the node-red dashboard on balenas cloud public url. What i can’t figure out is how to read the csv file from the node-red although it is located into the spi container.

Thank you in advance,
Dimitris

My docker-compose.yml file:

version: '2'
volumes:
    resin-data:
services:
  node-red:
    build: ./node-red
    volumes:
      - 'resin-data:/data'
    restart: always
    privileged: true
    network_mode: host
    labels:
      io.balena.features.supervisor-api: '1'
    cap_add:
      - SYS_RAWIO
    devices:
      - "/dev/mem:/dev/mem"
      - "/dev/gpiomem:/dev/gpiomem"
      - "/dev/i2c-1:/dev/i2c-1"
    ports:
      - 80:80
    
  spi_read_store:
    build: ./Multi_spi
    volumes:
      - 'resin-data:/data'
    restart: always
    privileged: true

Hi Dimitris,

I tried successfully the following short docker-compose.yml file. The contents of the data folder was shared successfully between the containers:

version: '2'
volumes:
  resin-data:
services:
  one:
    build: ./one
    volumes:
      - resin-data:/data
  two:
    build: ./two
    volumes:
      - resin-data:/data

It looks like your approach is correct. What happens when you open consoles to the two containers and create a file in the data folder in one of them - does it appear in the other one?

Thanks,
Zahari

Hello Zahari,

Thank you for your reply,
I have successfully created a file in the data folder and i am able to see it by using both container consoles but when i run my application i keep getting an error of no such file or directory.
Specifically the error i am getting is the following one.

It looks like, although the file is being created, afterwards the app is somehow unable to find it.

Thanks,
Dimitris

Have you correctly specified the path to that file ?

Hello,

Afterall indeed the path wasn’t specified correctly. I was saving the path into a variable at the beginning of my code and then used that variable to declare where the file was, but the variable accidentally was changing value between those two actions.
Now everything works fine!

Thanks a lot,
Dimitris