Giter Site home page Giter Site logo

Comments (10)

gcgarner avatar gcgarner commented on May 22, 2024

Containers run in a sandbox that don't have access to the host file system. For nodred the host can see the contents of the "/data" folder by means of the volume mapping but as far as nodered is concerned the host is a totally different computer.

If you want to share files between nodered and the host then you will need to save it in the "bridge" of ~/IOTstack/volumes/nodered/data:/data. If there is a specific host file that you want to access you could make a symbolic link into the volume, that way it is in a convenient place in your host and in the /data folder in nodered. All files in the nodered volume have root permissions so you would need to take that into account

from iotstack.

Paulf007 avatar Paulf007 commented on May 22, 2024

Thank you Graham it makes sence and will have to look at the bridge option. Just one more thing on the tpoic. Where would the file be store if created in Node red?
Have a look at this flow.
[{"id":"30fa8a04.e5f166","type":"inject","z":"40aad96e.d871f8","name":"","topic":"","payload":"test","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":4440,"wires":[["413b64ee.bbbdac"]]},{"id":"413b64ee.bbbdac","type":"file","z":"40aad96e.d871f8","name":"","filename":"testfile.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":450,"y":4440,"wires":[["10a9ec01.ed6f64"]]},{"id":"10a9ec01.ed6f64","type":"debug","z":"40aad96e.d871f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":4440,"wires":[]}]
If you freate a new file where is it strored on the system? I just cant find any of the test files created

from iotstack.

gcgarner avatar gcgarner commented on May 22, 2024

Have a look at the screenshot below. And let me know if this makes it clearer. I just made a wiki entry on this. wiki link

The file name i specified was /data/test.txt and in the terminal I listed the files in ls ~/IOTstack/volumes/nodered/data

anything that gets created in the container in the /data folder appears in ~/IOTstack/volumes/nodered/data

Have a look at the docker-compose.yml file, it shows for each container (service) where the host file system is mapped to the container file system.

image

from iotstack.

gcgarner avatar gcgarner commented on May 22, 2024

Here is another two ways:
1 using hard links)
Linux gives you the ability to make links. So i can make link from a file in my home directory into the host using the ln source destination. You can link any file or directory into the container file system. Problem is are you going to remember what you linked and where in 6 months time? And Hard links are really difficult to trace.

image

2 using the volume command)
This one would be the better option.
The other method is you can simply use the docker-compose.yml file to make a link for you. In when you forget where you saved it you can easily go find it

    volumes:
      - ./volumes/nodered/data:/data
      - ~/myfolder/:/share

the next time you run docker-compose up -d it will create a new directory in nodered called /share and any files that were in ~/myfolder would be visible in the container

from iotstack.

Paulf007 avatar Paulf007 commented on May 22, 2024

Thank you Graham for the explanation the wiki cleared it up quite well. I guess one is getting near attempting to cater for "personal needs" and that would not be feasible.
One thought thou :
Looking at option 2 would it not be a good idea to have the shared folder linked for all the containers that could use it. That way you will have a central "data" folder that could link the applications.
Personally I think Openhab , Node red and Home Assistant could benefit from this.

from iotstack.

gcgarner avatar gcgarner commented on May 22, 2024

I think you hit the nail on the head with "personal needs" getting one solution that will fit everyone is very tricky. And so does sharing volumes between containers. Its quite easy to do the link but to make sure everyone has the correct read and write permissions is tricky.

And the whole point about containers are they are supposed to be separate from the host and each other for security...

from iotstack.

Paulf007 avatar Paulf007 commented on May 22, 2024

I agree but as Openhab / Home Assistant in quite a lot of cases use node-red as rules engine it could be a useful addition else maybe an alternative install.

from iotstack.

gcgarner avatar gcgarner commented on May 22, 2024

I'm not familiar with hassio, what would be a typical use case where you would need to share files between it and nodered? I can always find a way to get it working

from iotstack.

Paulf007 avatar Paulf007 commented on May 22, 2024

I use Openhab so with node-red I do most of my custom rules. The one way is that I have a network scan app that scans the network every x time. It then logs the Ip's extra. Once all is done I use node-red to write a simple index file to Openhab via Node red with MQTT. That way I keep track of all "custom" stuff. I also use a couple of TXT files to keep track of important soft switches. So should the Pi Restart it will read the last command status from the txt file (These used to be in Openhab so I moved it to the data file.).

As a note the more I think about it the more I think we could hold for a moment, at least until someone else also ask for the same thing, There quite a bit of other work that can take precedence over this.

from iotstack.

gcgarner avatar gcgarner commented on May 22, 2024

I think working in containers have some limitations. A quick look on the web and i found this on persistent variables in nodered. But for keeping logs a SQL database would work. That is just another thing to learn unfortunately as you are familiar with your workflow.

If another request comes in then it will be worth while making something available

from iotstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.