Help understanding how code is referenced in docker

Hi, I'm investigating some issues when deploying node-red docker container instance.

On my local machine, I got the node red project set up with git. Including Dockerfile and all the rest to run in docker. Code is stored in flows.json as normal. But I don't understand how flows.json is handled with this setup.

For example I use the following procedure:

  1. Build docker image (from project folder)
  2. Create and run container (with bind volume to project folder)
  3. Code is loaded as expected

If I run container without bind volume, flows.json now loads as expected. But if I bind volume to a new folder to test, flows.json isn't transferred and node-red starts up empty! What happened to flows.json?

I made the docker build based on an official github example, and while I modified a few parts, I didn't touch anything to do with flows.json.

Also, node red is located inside the container in /usr/src/node-red. But there is also a /data folder? And some files/folders seems to be duplicated across the two. Why? I guess for export purposes, but how are these synchronized? Why keep stuff like node_modules and package.json in both locations?

For example package.json now resides in 3 places:

  • /usr/src/node-red (container)
  • /data (container)
  • host project folder

Plan is to deploy this in azure (container instance) with bind mount to file share. Which I have managed partially, but not seeing all expected files and folders there.

Any thoughts or insight?

Under Docker the compose file I use lives and is started from /srv/docker/node-red

I only use one volume bind defined as /srv/docker/node-red/data:/data and as this drops everything I need to access into one directory and if I want to move everything this is all I change. I would not expect objects to move if I change this binding unless I copy / move them manually.

My package.json and flows files live in the ./data with the actual node-red modules residing in ./data/node_modules/ nothing is inside the container flow wise.

I'm not sure why you need to swap around though - it's easy enough to spin up another docker container for development / testing or am I missing something?

Thanks! This wasn't actually a problem to spin up docker container for development, as it works fine locally. My issue was rather when trying to deploy this to azure container instance with volume set to azure file share. There I'm not seeing files as expected, in particular flows.json.

Then, I tried experimenting doing something similar locally.

And if I run container without bind volume, it has flows.json. If I bind volume to project folder, it uses the pre-existing flows.json. But if I bind volume to a new folder, flows.json doesn't exist. And I guess that's equivalent to what I'm doing in azure when deploying there? Set volume to an empty location.

How can flows.json be copied to volume if it doesn't exist there already? Some other files are however copied to the new volume. Stuff like .npm, lib, node_modules and package.json.

Found a solution, copying flows.json in Dockerfile to some temporary location, then in entrypoint.sh copy it to /data, then it shows up in bind mount.

It's a hack so have to look deeper into a smoother way, but it is more of a docker topic than node red so I'll leave it at that here.

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