# Docker upgrade node version

**URL:** <https://discourse.nodered.org/t/docker-upgrade-node-version/76781>\
**Category:** General\
**Tags:** docker\
**Created:** [21 March 2023 12:57 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781 "2023-03-21T12:57:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AMWN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/amwn/32/41809_2.png) [@AMWN](https://discourse.nodered.org/u/AMWN)\
**Post date:** [21 March 2023 12:57 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/1 "2023-03-21T12:57:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [21 March 2023 13:02 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/2 "2023-03-21T13:02:55Z")

</div>

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](https://github.com/shantanoo-desai/node-red-slim)

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

> **[GitHub - wowu/docker-rollout: 🚀 Zero Downtime Deployment for Docker Compose](https://github.com/Wowu/docker-rollout)**
>
> 🚀 Zero Downtime Deployment for Docker Compose

but I cannot vouch for it

---

<div class="post-metadata">

**Author:** ![AMWN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/amwn/32/41809_2.png) [@AMWN](https://discourse.nodered.org/u/AMWN)\
**Post date:** [21 March 2023 20:00 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/3 "2023-03-21T20:00:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 March 2023 21:11 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/4 "2023-03-21T21:11:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AMWN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/amwn/32/41809_2.png) [@AMWN](https://discourse.nodered.org/u/AMWN)\
**Post date:** [22 March 2023 07:58 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/5 "2023-03-22T07:58:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 March 2023 08:16 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/6 "2023-03-22T08:16:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 March 2023 08:18 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/7 "2023-03-22T08:18:50Z")

</div>

In fact it is the [node red docker docs](https://nodered.org/docs/getting-started/docker).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 May 2023 08:19 UTC](https://discourse.nodered.org/t/docker-upgrade-node-version/76781/8 "2023-05-21T08:19:44Z")

</div>

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