janvda / balena-node-red-mqtt-nginx-TIG-stack

Composite docker application with "8" containers (2x Node-RED, 2x MQTT broker, Telegraf, InfluxDb, Grafana, Nginx) for deployment on Raspberry Pi through Balena.
Eclipse Public License 2.0
58 stars 42 forks source link

node-red install error: sudo: no tty present and no askpass program specified #17

Closed areohbe closed 4 years ago

areohbe commented 5 years ago

I am receiving the following errors from node-red and node-red-test installation scripts

[node-red-test]  sudo: no tty present and no askpass program specified
[mqtt]           [=========================================================] 100[node-red-test]
[mqtt]           [=========================================================] 100[node-red]       Removing intermediate container c3783464b4e2
[mqtt]           [=========================================================] 100[node-red]       The command '/bin/sh -c sudo npm install -g --unsafe-perm node-red-admin' returned a non-zero code: 1
[mqtt]           [=========================================================] 100[node-red-test]  Removing intermediate container 5dd7c9e2425b
[mqtt]           [=========================================================] 100[node-red-test]  The command '/bin/sh -c sudo npm install -g --unsafe-perm node-red-admin' returned a non-zero code: 1
janvda commented 5 years ago

Thanks for reporting this issue.

It seems like sudo is requiring you to enter a password which of course doesn't work in case of building an image from Dockerfile.

As workaround I would remove the line: RUN sudo npm install -g --unsafe-perm node-red-admin from the node-red and node-red-test Dockerfile.

The disadvantage is that the node-red-admin utility will not be installed which is not needed for normal operation of node-red. You only need that utility if you want to create a hashed password for the node-red editor. Of course if you have the utility installed somewhere else you can use it there to create a hashed password.

janvda commented 5 years ago

I think following file describes how it can be solved: https://github.com/janvda/balena-kodi-etcetera/blob/master/node-red/Dockerfile

So remove the following line in the node-red and node-red-test Dockerfile

RUN sudo npm install -g --unsafe-perm node-red-admin

and add following line just after USER root

RUN npm install -g --unsafe-perm node-red-admin