首页 > 解决方案 > Mapping Ports with Azure Docker Containers

问题描述

Is there a way in Azure to map ports to a Docker container? I have an image I've build using Node + Express that takes in an environmental variable to determine which port to listen on. In Azure, using any port over 1024 seems to work fine, but below that the process raises an uncaughtException error. Obviously I'd like to use port 80 (and 443) for production. I'd like to map port 80 to a configured port within my container (e.g. docker run -p 80:3000. How can I accomplish this within Azure.

The error raised when mapping to port 80 is:

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 }

Thank you in advance for the help!

标签: node.jsazuredockerexpresscontainers

解决方案


很确定这还不被支持,你可以在这里投票支持这个功能。

此外,查看文档,似乎端口 80 应该可以正常工作(请参阅示例)。


推荐阅读