Docker upgrade node version

What is the right procedure to update node js version in a node-red docker environment?

Right now I run multiple node-red containers with node version 14.20, defined in a docker-compose file.I installed various packages by manualy installing, or by pallet manager.

Soon, (next node-red release 3.1.0), I want to upgrade the node js version to 16 or 18. I'll build a new docker image bases on the official node-red docker image with node version 16. Then I'll change the docker-compose file to the new docker-image 3.1 with node version 16.

This works perfect when node version of previous container is the same. But when upgrading the container to a new node js version, the docker volume npm node_modules in the projectfolder will have an older version. How can I seemlesly upgrade the volume project folder?

Last time I tried this the node-red docker container won't start at all, so I could not manually upgrade (rebuild?) the project npm folder.

Anyone has some advice how to realise this with minimum downtime?

I mean the updated node-red/nodered:3.0.1 should have the updated node versions in them. If you aren't sure have a look at this project GitHub - shantanoo-desai/node-red-slim: A Slim Node-RED Docker Image with Alpine Container using Docker Multistage Builds

You cannot have smooth transitions when your docker images are pinned to version in docker-compose. If you images are all pinned to latest tags then the transitions can be easier because docker only pulls the diff of the images. However from e.g., 2.0 -> 3.0 will require you docker compose down and docker compose up again

Potential Tool for smoother roll-out

but I cannot vouch for it

Thanks for you reply. Docker compose down and docker compose up isn't a problem for me. It takes about 30 seconds. Which is fine in my case.

Biggest issue is that the node_modules in the project folder (docker volume) are of older version that the node version of the docker container. How to rebuild the packages?

I don't know about docker, but for a normal install one would go into the .node-red folder (where the flows file is) and run
npm rebuild
which will rebuild any nodes that need it. Presumably in a docker environment one should do that in a shell inside the container.

Hi Colin, you're right about that. But de docker container won't start, probably because node-red can't start, so I can't get in to it and run npm rebuild.

Start node-red in safe mode so that it does not run the flows. I don't remember how to do that but it was discussed here recently. Search the forum for Docker safe mode, or even google for
node red safe mode docker
and I am sure you will find the solution.

In fact it is the node red docker docs.

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