【发布时间】:2019-08-28 06:38:54
【问题描述】:
Azure 中有没有办法将端口映射到 Docker 容器?我有一个使用 Node + Express 构建的图像,它接受一个环境变量来确定要监听的端口。在 Azure 中,使用超过 1024 的任何端口似乎都可以正常工作,但低于该进程会引发 uncaughtException 错误。显然我想使用端口 80(和 443)进行生产。我想将端口 80 映射到容器中的配置端口(例如 docker run -p 80:3000。如何在 Azure 中完成此操作。
映射到80端口时出现的错误是:
server port is 80
{ Error: listen EACCES: permission denied 0.0.0.0:80
at Server.setupListenHandle [as _listen2] (net.js:1241:19)
at listenInCluster (net.js:1306:12)
at Server.listen (net.js:1394:7)
at Function.listen (/home/node/app/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/node/app/dist/app.js:34:5)
at Module._compile (internal/modules/cjs/loader.js:805:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:816:10)
at Module.load (internal/modules/cjs/loader.js:672:32)
at tryModuleLoad (internal/modules/cjs/loader.js:612:12)
at Function.Module._load (internal/modules/cjs/loader.js:604:3)
code: 'EACCES',
errno: 'EACCES',
syscall: 'listen',
address: '0.0.0.0',
port: 80 }
提前感谢您的帮助!
【问题讨论】:
-
您使用哪种 Azure 服务? Azure VM 还是 Azure 容器实例?
标签: node.js azure docker express containers