2
2

More than 5 years have passed since last update.

Docker+node+express且つnodeユーザー+80番ポートでexpress起動できなかった件

Last updated at Posted at 2017-05-05

自分用の覚書

環境

ver
Docker 1.11.2
node 7.9-alpine
express 4.15.2

症状

$ docker run --rm -it --user node node:7.9-alpine ash

$ cd /home/node
$ yarn add express
$ node -i
> const express = require('express');
> const app = express();
> app.listen(80, () => { console.log('listen on port 80'); });
Server {
~ 割愛 ~
  maxHeadersCount: null }
> Error: listen EACCES 0.0.0.0:80
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at Server.setupListenHandle [as _listen2] (net.js:1247:19)
    at listenInCluster (net.js:1304:12)
    at Server.listen (net.js:1402:7)
    at Function.listen (/opt/node_modules/express/lib/application.js:618:24)
    at repl:1:5
    at ContextifyScript.Script.runInThisContext (vm.js:23:33)
    at REPLServer.defaultEval (repl.js:339:29)
    at bound (domain.js:280:14)

参考

ポート番号を変えると良い的な

対処

$ docker run --rm -it --user node node:7.9-alpine ash

$ cd /home/node
$ yarn add express
$ node -i
> const express = require('express');
> const app = express();
> app.listen(18081, () => { console.log('listen on port 18081'); });
Server {
~ 割愛 ~
  _connectionKey: '6::::18081' }
> listen on port 18081

最後に

rootユーザーなら起動できる

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2