如何使用 Dockerfile 在 Heroku 上公开端口? [英] How do I expose ports on Heroku with a Dockerfile?
问题描述
我正在尝试在 Heroku 上部署一个 Docker 镜像,并试图了解如何公开多个端口.这是我尝试在 Heroku 部署中运行的 Docker 命令:
I am trying to deploy a Docker image on Heroku and am trying to understand how to expose multiple ports. Here is the Docker command that I am trying to run in the Heroku deploy:
docker run
-p 2222:22
-p 33306:3306
-p 27017:27017
-p 28015:28015
-p 29015:29015
-p 8080:8080
test/db-migration
如何在 Heroku 中执行此操作?
How do I do this in Heroku?
推荐答案
你不能 - 你应该使用 $PORT 环境变量,它会随机分配,然后由 Heroku 路由器映射到端口 80.此外,仅接受 http 请求.请参阅 https://devcenter.heroku.com/文章/container-registry-and-runtime#dockerfile-commands-and-runtime 了解更多详情.
You can't - you should use the $PORT environment variable which will be randomly assigned and then mapped to port 80 by the Heroku routers. Also, only http requests are accepted. See https://devcenter.heroku.com/articles/container-registry-and-runtime#dockerfile-commands-and-runtime for more details.
这篇关于如何使用 Dockerfile 在 Heroku 上公开端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!