title: How do I run Docker in Docker on Heroku?
body: <p>Why?<br>
  I'm trying to create a general purpose solution for running docker-compose on Heroku. I want to make a one click deployment solution through the use of Heroku Button deployment. This way, a user does not need any knowledge of git, Heroku cli and docker.</p>
  
  <p>The problem.<br>
  Docker and the docker daemon are only available when I set the <code>stack</code> to <code>container</code>. There are buildpacks that give you docker and docker-compose CLI but without the docker daemon you cannot run the docker image. So buildpacks won't work.<br>
  With the <code>stack</code> set to <code>container</code> I can use the file <code>heroku.yml</code> (<a href="https://devcenter.heroku.com/articles/build-docker-images-heroku-yml" rel="noreferrer">article</a>). In there I define my processes. (It replaces <code>Procfile</code>. If I still add a <code>Procfile</code> to my project it will do nothing.)<br>
  I can also define a <code>Dockerfile</code> there to build my docker image.<br>
  When I however run the docker image the following error pops up:  </p>
  
  <pre><code>2019-02-28T15:32:48.462101+00:00 app[worker.1]: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
  2019-02-28T15:32:48.462119+00:00 app[worker.1]: 
  2019-02-28T15:32:48.462122+00:00 app[worker.1]: If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
  </code></pre>
  
  <p>The problem is inside the Docker container the Docker daemon is not running. The solution to this is to mount it:<br>
  <code>docker run -v /var/run/docker.sock:/var/run/docker.sock ...</code><br>
  And since you cannot use <code>Procfile</code> I cannot run that command. (See above <code>heroku.yml</code> replaces <code>Procfile</code>.) And if I was using a buildpack I could use <code>Procfile</code> but the docker daemon wouldn't be running.....</p>
  
  <p>I tried defining a <code>VOLUME</code> within the <code>Dockerfile</code> and the problem persists. Furthermore a heroku article says <a href="https://devcenter.heroku.com/articles/container-registry-and-runtime" rel="noreferrer">"Volume mounting is not supported. The filesystem of the dyno is ephemeral."</a></p>
  
  <p>On Heroku it is possible to run a docker image. What I am struggling at is running a docker in docker image.<br>
  Running a docker in docker image works fine on my VPS by mounting <code>/var/run/docker.sock</code> but this cannot(?) be done on Heroku.</p>
  
  <p>Last words: 
  I'm trying to make this work so that other people can easily deploy software solution even though they are not comfortable with git, heroku cli and docker. </p>