We looked at how we can extend to some other external platforms such as cloud services like AWS, Microsoft Azure, and DigitalOcean before. In this section, we will focus on extending Docker to the Heroku platform. Heroku is more a little different than those cloud services; it is considered a Platform as a Service (PaaS). Instead of deploying containers to it, you can link your containers to the Heroku platform from which it is running a service, such as PHP, Java, Node.js, Python, or many others. So, you can run your rails application on Heroku and then attach your Docker container to that platform.
The way you can use Docker and Heroku together is by creating your application on the Heroku platform. Then, in your code, you will have something similar to the following:
{ "name": "Application Name", "description": "Application to run code in a Docker container", "image": "<docker_image>:<tag>", "addons": [ "heroku-postgresql" ] }
To take a step back, we first need to install a plugin to be able to get this functionality working. To install it, we will simply run:
$ heroku plugins:install heroku-docker
Now, if you are wondering what image you can or should be using from Docker Hub, Heroku maintains a lot of images you can use in the preceding code. They are as follows:
heroku/nodejs heroku/ruby heroku/jruby heroku/python heroku/scala heroku/clojure heroku/gradle heroku/java heroku/go heroku/go-gb