如何使用Dockerfile公开Heroku上的端口? [英] How do I expose ports on Heroku with a Dockerfile?

查看:111
本文介绍了如何使用Dockerfile公开Heroku上的端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在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/ article / 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆