Error: listen EACCES 0.0.0.0:80 when deploying docker image nodered/node-red-docker:rpi-v8 using resin.io on raspberry pi3
Error: listen EACCES 0.0.0.0:80 when deploying docker image nodered/node-red-docker:rpi-v8 using resin.io on raspberry pi3
使用 resin.io 我尝试将包含以下内容(仅 1 行)的 Docker 文件部署到我的 Raspberry pi 设备。
FROM nodered/node-red-docker:rpi-v8
resin.io 成功构建映像(请参阅以下日志):
[Success] Successfully uploaded images
[Success] Release successfully created!
[Info] Release: ff11126a791e453d6790b9702290cd5a962c79f6 (id: 646158)
[Info] ┌─────────┬────────────┬────────────┐
[Info] │ Service │ Image Size │ Build Time │
[Info] ├─────────┼────────────┼────────────┤
[Info] │ main │ 536.19 MB │ 26 seconds │
[Info] └─────────┴────────────┴────────────┘
[Info] Build finished in 1 minute, 20 seconds
\
\
\
\
>\/7
_.-(6' \
(=___._/` \
) \ |
/ / |
/ > /
j < _\
_.-' : ``.
\ r=._\ `.
<`\_ \ .`-.
\ r-7 `-. ._ ' . `\
\`, `-.`7 7) )
\/ \| \' / `-._
|| .'
\ (
>\ >
,.-' >.'
<.'_.''
<'
To git.resin.io:gh_janvda/pi3four.git
+ 173e46e...ff11126 master -> master (forced update)
但是在 raspberry pi 设备上部署它时报告了以下错误:
27.10.18 23:14:51 (+0200) main mount: only root can use "--types" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main umount: /dev: umount failed: Operation not permitted
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main ln: cannot remove ‘/dev/ptmx’: Permission denied
27.10.18 23:14:51 (+0200) main mount: only root can use "--types" option
27.10.18 23:14:51 (+0200) main /sbin/udevd
27.10.18 23:14:52 (+0200) main npm info it worked if it ends with ok
27.10.18 23:14:52 (+0200) main npm info using npm@5.0.3
27.10.18 23:14:52 (+0200) main npm info using node@v8.1.3
27.10.18 23:14:53 (+0200) main [..................] \ : verb config Skipping project config: /usr/srcnpm info lifecycle node-red-docker@1.0.0~prestart: node-red-docker@1.0.0
27.10.18 23:14:53 (+0200) main [..................] / : info lifecycle node-red-docker@1.0.0~prestartnpm info lifecycle node-red-docker@1.0.0~start: node-red-docker@1.0.0
27.10.18 23:14:53 (+0200) main
27.10.18 23:14:53 (+0200) main > node-red-docker@1.0.0 start /usr/src/node-red
27.10.18 23:14:53 (+0200) main > node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
27.10.18 23:14:53 (+0200) main
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info]
27.10.18 23:14:55 (+0200) main
27.10.18 23:14:55 (+0200) main Welcome to Node-RED
27.10.18 23:14:55 (+0200) main ===================
27.10.18 23:14:55 (+0200) main
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info] Node-RED version: v0.19.4
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info] Node.js version: v8.1.3
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info] Linux 4.14.39 arm LE
27.10.18 23:14:56 (+0200) main 27 Oct 21:14:56 - [info] Loading palette nodes
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Settings file : /data/settings.js
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Context store : 'default' [module=memory]
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] User directory : /data
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Flows file : /data/flows.json
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Creating new flow file
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [warn]
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main ---------------------------------------------------------------------
27.10.18 23:15:00 (+0200) main Your flow credentials file is encrypted using a system-generated key.
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main If the system-generated key is lost for any reason, your credentials
27.10.18 23:15:00 (+0200) main file will not be recoverable, you will have to delete it and re-enter
27.10.18 23:15:00 (+0200) main your credentials.
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main You should set your own key using the 'credentialSecret' option in
27.10.18 23:15:00 (+0200) main your settings file. Node-RED will then re-encrypt your credentials
27.10.18 23:15:00 (+0200) main file using your chosen key the next time you deploy a change.
27.10.18 23:15:00 (+0200) main ---------------------------------------------------------------------
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Starting flows
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Started flows
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [error] Uncaught Exception:
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [error] Error: listen EACCES 0.0.0.0:80
27.10.18 23:15:00 (+0200) main at Object.exports._errnoException (util.js:1022:11)
27.10.18 23:15:00 (+0200) main at exports._exceptionWithHostPort (util.js:1045:20)
27.10.18 23:15:00 (+0200) main at Server.setupListenHandle [as _listen2] (net.js:1298:19)
27.10.18 23:15:00 (+0200) main at listenInCluster (net.js:1363:12)
27.10.18 23:15:00 (+0200) main at doListen (net.js:1489:7)
27.10.18 23:15:00 (+0200) main at _combinedTickCallback (internal/process/next_tick.js:105:11)
27.10.18 23:15:00 (+0200) main at process._tickCallback (internal/process/next_tick.js:161:9)
27.10.18 23:15:00 (+0200) main npm info lifecycle node-red-docker@1.0.0~start: Failed to exec start script
27.10.18 23:15:00 (+0200) main npm ERR! code ELIFECYCLE
27.10.18 23:15:00 (+0200) main npm ERR! errno 1
27.10.18 23:15:00 (+0200) main npm ERR! node-red-docker@1.0.0 start: `node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"`
27.10.18 23:15:00 (+0200) main npm ERR! Exit status 1
27.10.18 23:15:00 (+0200) main npm ERR!
27.10.18 23:15:00 (+0200) main npm ERR! Failed at the node-red-docker@1.0.0 start script.
27.10.18 23:15:00 (+0200) main npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main npm ERR! A complete log of this run can be found in:
27.10.18 23:15:00 (+0200) main npm ERR! /usr/src/node-red/.npm/_logs/2018-10-27T21_15_00_316Z-debug.log
根据我的说法,主要错误是:
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [error] Error: listen EACCES 0.0.0.0:80
所以这意味着 Node-RED 正在侦听端口 80,这是不允许的,因为用户不是 root。
我认为可以通过配置 node-red 使其不侦听端口 80 而是侦听端口 1880 来修复此错误。我不清楚如何在我想要的特定场景中执行此操作使用 Docker 图像 nodered/node-red-docker:rpi-v8 我想用 resin.io.
部署
我的问题:部署镜像时如何保证Node-RED监听1880端口nodered/node-red-docker:rpi-v8 使用 resin.io ?
- 我注意到我的 raspberry pi 设备的设备服务变量 "PORT" 在 resin.io 中设置为 80。因此,通过将其更改为 1880 来解决此问题。
仅供参考:它设置为 80,因为我已经部署了 https://github.com/resin-io-projects/balena-node-red,为此我必须将端口设置为 80。
- 或者,我们可以通过如下更改 Dockerfile(添加最后 3 行)来允许
node
应用程序侦听任何端口。这种方法的优点是我们可以继续使用端口 80,这意味着我们可以使用 public url 提供的 public url 通过互联网访问 Node-RED 编辑器和 Node-RED ui =13=]
FROM nodered/node-red-docker:rpi-v8
USER root
RUN sudo setcap 'cap_net_bind_service=+ep' $(eval readlink -f `which node`)
USER node-red
使用 resin.io 我尝试将包含以下内容(仅 1 行)的 Docker 文件部署到我的 Raspberry pi 设备。
FROM nodered/node-red-docker:rpi-v8
resin.io 成功构建映像(请参阅以下日志):
[Success] Successfully uploaded images
[Success] Release successfully created!
[Info] Release: ff11126a791e453d6790b9702290cd5a962c79f6 (id: 646158)
[Info] ┌─────────┬────────────┬────────────┐
[Info] │ Service │ Image Size │ Build Time │
[Info] ├─────────┼────────────┼────────────┤
[Info] │ main │ 536.19 MB │ 26 seconds │
[Info] └─────────┴────────────┴────────────┘
[Info] Build finished in 1 minute, 20 seconds
\
\
\
\
>\/7
_.-(6' \
(=___._/` \
) \ |
/ / |
/ > /
j < _\
_.-' : ``.
\ r=._\ `.
<`\_ \ .`-.
\ r-7 `-. ._ ' . `\
\`, `-.`7 7) )
\/ \| \' / `-._
|| .'
\ (
>\ >
,.-' >.'
<.'_.''
<'
To git.resin.io:gh_janvda/pi3four.git
+ 173e46e...ff11126 master -> master (forced update)
但是在 raspberry pi 设备上部署它时报告了以下错误:
27.10.18 23:14:51 (+0200) main mount: only root can use "--types" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main umount: /dev: umount failed: Operation not permitted
27.10.18 23:14:51 (+0200) main mount: only root can use "--move" option
27.10.18 23:14:51 (+0200) main ln: cannot remove ‘/dev/ptmx’: Permission denied
27.10.18 23:14:51 (+0200) main mount: only root can use "--types" option
27.10.18 23:14:51 (+0200) main /sbin/udevd
27.10.18 23:14:52 (+0200) main npm info it worked if it ends with ok
27.10.18 23:14:52 (+0200) main npm info using npm@5.0.3
27.10.18 23:14:52 (+0200) main npm info using node@v8.1.3
27.10.18 23:14:53 (+0200) main [..................] \ : verb config Skipping project config: /usr/srcnpm info lifecycle node-red-docker@1.0.0~prestart: node-red-docker@1.0.0
27.10.18 23:14:53 (+0200) main [..................] / : info lifecycle node-red-docker@1.0.0~prestartnpm info lifecycle node-red-docker@1.0.0~start: node-red-docker@1.0.0
27.10.18 23:14:53 (+0200) main
27.10.18 23:14:53 (+0200) main > node-red-docker@1.0.0 start /usr/src/node-red
27.10.18 23:14:53 (+0200) main > node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
27.10.18 23:14:53 (+0200) main
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info]
27.10.18 23:14:55 (+0200) main
27.10.18 23:14:55 (+0200) main Welcome to Node-RED
27.10.18 23:14:55 (+0200) main ===================
27.10.18 23:14:55 (+0200) main
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info] Node-RED version: v0.19.4
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info] Node.js version: v8.1.3
27.10.18 23:14:55 (+0200) main 27 Oct 21:14:55 - [info] Linux 4.14.39 arm LE
27.10.18 23:14:56 (+0200) main 27 Oct 21:14:56 - [info] Loading palette nodes
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Settings file : /data/settings.js
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Context store : 'default' [module=memory]
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] User directory : /data
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Flows file : /data/flows.json
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Creating new flow file
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [warn]
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main ---------------------------------------------------------------------
27.10.18 23:15:00 (+0200) main Your flow credentials file is encrypted using a system-generated key.
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main If the system-generated key is lost for any reason, your credentials
27.10.18 23:15:00 (+0200) main file will not be recoverable, you will have to delete it and re-enter
27.10.18 23:15:00 (+0200) main your credentials.
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main You should set your own key using the 'credentialSecret' option in
27.10.18 23:15:00 (+0200) main your settings file. Node-RED will then re-encrypt your credentials
27.10.18 23:15:00 (+0200) main file using your chosen key the next time you deploy a change.
27.10.18 23:15:00 (+0200) main ---------------------------------------------------------------------
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Starting flows
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [info] Started flows
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [error] Uncaught Exception:
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [error] Error: listen EACCES 0.0.0.0:80
27.10.18 23:15:00 (+0200) main at Object.exports._errnoException (util.js:1022:11)
27.10.18 23:15:00 (+0200) main at exports._exceptionWithHostPort (util.js:1045:20)
27.10.18 23:15:00 (+0200) main at Server.setupListenHandle [as _listen2] (net.js:1298:19)
27.10.18 23:15:00 (+0200) main at listenInCluster (net.js:1363:12)
27.10.18 23:15:00 (+0200) main at doListen (net.js:1489:7)
27.10.18 23:15:00 (+0200) main at _combinedTickCallback (internal/process/next_tick.js:105:11)
27.10.18 23:15:00 (+0200) main at process._tickCallback (internal/process/next_tick.js:161:9)
27.10.18 23:15:00 (+0200) main npm info lifecycle node-red-docker@1.0.0~start: Failed to exec start script
27.10.18 23:15:00 (+0200) main npm ERR! code ELIFECYCLE
27.10.18 23:15:00 (+0200) main npm ERR! errno 1
27.10.18 23:15:00 (+0200) main npm ERR! node-red-docker@1.0.0 start: `node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"`
27.10.18 23:15:00 (+0200) main npm ERR! Exit status 1
27.10.18 23:15:00 (+0200) main npm ERR!
27.10.18 23:15:00 (+0200) main npm ERR! Failed at the node-red-docker@1.0.0 start script.
27.10.18 23:15:00 (+0200) main npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
27.10.18 23:15:00 (+0200) main
27.10.18 23:15:00 (+0200) main npm ERR! A complete log of this run can be found in:
27.10.18 23:15:00 (+0200) main npm ERR! /usr/src/node-red/.npm/_logs/2018-10-27T21_15_00_316Z-debug.log
根据我的说法,主要错误是:
27.10.18 23:15:00 (+0200) main 27 Oct 21:15:00 - [error] Error: listen EACCES 0.0.0.0:80
所以这意味着 Node-RED 正在侦听端口 80,这是不允许的,因为用户不是 root。
我认为可以通过配置 node-red 使其不侦听端口 80 而是侦听端口 1880 来修复此错误。我不清楚如何在我想要的特定场景中执行此操作使用 Docker 图像 nodered/node-red-docker:rpi-v8 我想用 resin.io.
部署我的问题:部署镜像时如何保证Node-RED监听1880端口nodered/node-red-docker:rpi-v8 使用 resin.io ?
- 我注意到我的 raspberry pi 设备的设备服务变量 "PORT" 在 resin.io 中设置为 80。因此,通过将其更改为 1880 来解决此问题。
仅供参考:它设置为 80,因为我已经部署了 https://github.com/resin-io-projects/balena-node-red,为此我必须将端口设置为 80。
- 或者,我们可以通过如下更改 Dockerfile(添加最后 3 行)来允许
node
应用程序侦听任何端口。这种方法的优点是我们可以继续使用端口 80,这意味着我们可以使用 public url 提供的 public url 通过互联网访问 Node-RED 编辑器和 Node-RED ui =13=]
FROM nodered/node-red-docker:rpi-v8 USER root RUN sudo setcap 'cap_net_bind_service=+ep' $(eval readlink -f `which node`) USER node-red