Deploy Django — docker application into heroku

Eby Sofyan
2 min readMay 16, 2019


source :

Develop an application sometime running smoothly. But have you deploy your great application in hosting or virtual machine? Have you ever experienced something like a shit? Working well on your local machine but error in your virtual machine or hosting. If you have been in that situation, we are the same. Then? how to made is simpler? I wanna deploy my application without think about so many consideration such as hosting and or virtual machine specification.

Dockerize your application and deploy it on heroku, trust me it’s works

Make it simpler by following this step

Step 1. Create your app on heroku dashboard.

Step 2. Make sure heroku-cli already installed on your machine. If not, install it first by following this instruction.

Step 3. Create Dockerfile on your django project that ready to deploye. Example Dockerfile content below or you can create your own.

FROM python:3.6ADD . /webapp/WORKDIR /webappRUN pip install --upgrade pipRUN pip install -r /webapp/requirements.txtRUN python collectstaticRUN python makemigrations && python migrateCMD gunicorn --bind$PORT config.wsgi

Focus on last line of the Dockerfile, variable $PORT is dynamically set by heroku. Make sure to list gunicorn on your requirements.txt

Step 4. Sign in to heroku using heroku-cli

heroku login

Step 5. Sign in to heroku container registry to register your application and make it ready to using docker.

heroku container:login

Step 6. By logged in to heroku container, your application ready to deploy using docker.

heroku container:push web -a your_application_name

This command will make your application store into heroku registry storage and ready to deploy.

**your_application_name is name of your application that you create first on your heroku dashboard.

Step 7. This is last instruction to make your application fully deployed.

heroku container:release web -a your_application_name

That’s it. Your application is now online and make it accessible wherever your are.

Now, go ahead and clap for this article if it usefull. Thank you.



Eby Sofyan

Software developer with almost 3 years experience especially in Backend and Android Developmnet. Using Django and Kotlin as weapon.