How do I run Docker in Docker on Heroku? How do I run Docker in Docker on Heroku? docker docker

How do I run Docker in Docker on Heroku?


Unfortunately the answer to your question is: not yet.

For securiy reasons Heroku does not provide to the users the ability to run priviledged containers because the container could access to host capabilities.The documentation is pretty clear about your limitations, e.g: No --priviledged container and no root user either, no VOLUMES and disk is ephemeral.

After playing with DinD images for your concern, I came to the conclusion that trying to run Docker inside a Heroku container is not the right choice and design.I am pretty sure what you are trying to achieve is close to what Heroku is offering to the users. Offering a platform or an application where non-developper can push and deploy applications with just a button can be very interesting in various ways. And it can be done with an application using their Platform API.In this situation a Web application (running on Heroku) may not (up to my knowledge) be able to do what you want. Instead you need to embed in a Desktop application: git, docker, and your app for parsing, verifying, building and pushing your applications/components to Heroku's container registry.

In the end, if you still think what you need a DinD solution, well, your primary solution to use a VPS is the only solution for the moment. But be aware that it may open security vulnerabilities to your system and you may arrive to offer something similar to Heroku's offer when trying to limit those security doors.


I don't think you can run a service on Heroku that can use the docker command to start some docker container.

I want to make a one click deployment solution through the use of Heroku Button deployment.

I think you can update the reference of the Deploy button to some of your automation servers (ex: an instance Jenkins already deploy on Heroku/another cloud) to trigger the deploy pipeline and don't let people interact with git/docker, etc.
But yes, you have to deal with a lot of problems like security, parameter. when not using popular solutions like Jenkins/CircleCI login and then deploy...


What I did was install it in my dockerfile like this:

RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz \  && tar xzvf docker-17.04.0-ce.tgz \  && mv docker/docker /usr/local/bin \  && rm -r docker docker-17.04.0-ce.tgz

Then in the args section for running the docker I added this:

args '--user root -v /var/run/docker.sock:/var/run/docker.sock'

For further explanation on why this works see: stackoverflow.com/q/27879713/354577 This works well for me though.