jhamm
jhamm

Reputation: 25032

How do I expose ports on Heroku with a Dockerfile?

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

How do I do this in Heroku?

Upvotes: 16

Views: 19375

Answers (2)

user670908
user670908

Reputation: 311

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.

Upvotes: 0

John Beynon
John Beynon

Reputation: 37507

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.

Upvotes: 22

Related Questions