/ heroku

Heroku Docker Deployments

Level - Intermediate. Read Time ~ <5 minutes.


If you get the below error. Check your user has deploy permission and your Docker image has less than 40 layers.

error parsing HTTP 400 response body: unexpected end of JSON input: ""

Fix Deployment Error

Deploying Docker images to Heroku is generally a straight forward process. By following their official documentation, you should be able to hit the ground running very quickly. The basic premise is as follows: -

  • Login to the registry
  • Build or tag an existing
  • Push to the registry
  • Release image from the registry

So, I've done all the above but I get the mysterious 400 response error on pushing to the registry as per below: -

error parsing HTTP 400 response body: unexpected end of JSON input: ""


After digging around online and looking through the Heroku documentation, we discovered the following section. So one of the issues is the Docker image having greater than 40 layers. To check your layers, run this command: -

docker history -q <IMAGE_ID> | wc -l

This is a useful article to help with reducing your number of layers.

The actual issue we had was that the account performing the docker login and the subsequent docker push, did not have deploy permission. When we changed this, everything started working. For guidance on roles and app permmisions you can look here. In our case the deploy permission was critical to be able to push.