How do I expose ports on Heroku with a Dockerfile? How do I expose ports on Heroku with a Dockerfile? heroku heroku

How do I expose ports on Heroku with a Dockerfile?


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.


You may want to look at Dockhero add-on. It's a good way to deploy supplementary resources alongside your Heroku app, and it supports docker-compose with multi-port mapping. The web app itself should still be running on Heroku dynos.