How to correct errors and append new stuff in docker-compose.yml the right way?

I have two questions which are related but which I’ll keep separate for clarity:
Question 1:
My current docker-compose.yml looks like this:

services:
 rhasspy:
  image: rhasspy/rhasspy
  container_name: rhasspy
  restart: always
  volumes:
   - /home/pi/containers/rhasspy/profiles:/profiles
  ports:
   - 12101:12101
  devices:
   - /dev/snd:/dev/snd
  command: --user-profiles /profiles --profile nl    
 node-red:
  image: nodered/node-red
  container_name: node-red
  restart: always
      volumes:
       - ./node-red:/data
  ports:
   - 1880:1880
   - 1883:1883
  environment:
   - TZ=Europe/Brussels

As I want to follow the instructions from the “Control Your Home with Raspberry Pi”-book closer.
I’d like to replace (after a mkdir /home/pi/containers/node-red ) this part:

    volumes:
        - ./node-red:/data

by this:

volumes:
    - ./containers/node-red:/data
    - ./containers/certificates:/etc/ssl/private:ro
    - /etc/localtime:/etc/localtime:ro

So far so good. My question now is how can I make my system take over the changed configuration without screwing the whole docker-thing. Just doing the following is probably not the right way:

docker-compose down -d
docker-compose pull
docker-compose up -d

Question 2:
Suppose I want to add a part for mosquitto in docker-compose.yml
Should the complete file then look like this:

version: '3.7'

services:
 rhasspy:
  image: rhasspy/rhasspy
  container_name: rhasspy
  restart: always
  volumes:
   - /home/pi/containers/rhasspy/profiles:/profiles
  ports:
   - 12101:12101
  devices:
   - /dev/snd:/dev/snd
  command: --user-profiles /profiles --profile nl    
 node-red:
  image: nodered/node-red
  container_name: node-red
  restart: always
  volumes:
   - ./containers/node-red:/data
   - ./containers/certificates:/etc/ssl/private:ro
   - /etc/localtime:/etc/localtime:ro
  ports:
   - 1880:1880
   - 1883:1883
  environment:
   - TZ=Europe/Brussels
  mosquitto:
   image: eclipse-mosquitto
   container_name: mosquitto
   restart: always
   ports:
    - "1883:1883"
    - "9001:9001"
   volumes:
    - ./containers/mosquitto/config:/mosquitto/config
    - ./containers/mosquitto/data:/mosquitto/data
    - ./containers/mosquitto/log:/mosquitto/log
    - /etc/localtime:/etc/localtime:ro
   user: "1000:1000"

Which docker-compose commands should I use then to perform the update properly?

kind regards,
hugo

The answer to both questions is the same: a docker-compose up -d should suffice.

From its documentation:

If there are existing containers for a service, and the service’s configuration or image was changed after the container’s creation, docker-compose up picks up the changes by stopping and recreating the containers (preserving mounted volumes).

The added mosquitto service looks fine.

I had to use vim and yamllint to hunt for indendation spaces. Once that solved, installation failed because I had two port enties 1883:1883 in the file. I deleted one in the node-red section and then docker-compose up did its thing. I than did test the workings of mosquitto using mosquitt_sub -t ‘#’ and
mosquitto_pub -t ‘test/foobar’ -m ‘test message’. It worked fine. But then came the great desillusion:
My node-red flows didn’t work anymore. I thought no problem I’ll import one I backupped but to no avail:
node-red started complaining:

Flows stopped due to missing node types.

ui_group
ui_tab
ui_base
ui_spacer
mosca in
ui_switch
ui_button
ui_text
ui_gauge
openweathermap
ui_chart
ui_audio
ui_template

I tried to reinstall “node-red-dashboard” via “manage palette” but nothing happens (the thing seems to wait for something endlessly, the log just shows:2020-08-24T15:21:48.421Z Install : node-red-dashboard 2.23.2 ). Then I did this:
docker exec -it node-red bash
npm install node-red-dashboard

but this too was a failure… :frowning:

hugo
For those interested, this is the working docker-compose.yml

https://www.dropbox.com/s/0eotick6haqfdj1/docker-compose.yml?dl=1

Didn’t you copy your existing Node-RED data directory .node-red to ./containers/node-red first?

Didn’t you copy .node-red to ./containers/node-red first?

No I didn’t, thought it was better to start with a “fresh install”. I have now removed ./containers/node-red and then moved the original node-red directory to its place and it works again!

thanks for helping me out (once more)
kind regards,
hugo