Why?
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.
The problem.
Docker and the docker daemon are only available when I set the stack
to container
. 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.
With the stack
set to container
I can use the file heroku.yml
(article). In there I define my processes. (It replaces Procfile
. If I still add a Procfile
to my project it will do nothing.)
I can also define a Dockerfile
there to build my docker image.
When I however run the docker image the following error pops up:
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.
The problem is inside the Docker container the Docker daemon is not running. The solution to this is to mount it:
docker run -v /var/run/docker.sock:/var/run/docker.sock ...
And since you cannot use Procfile
I cannot run that command. (See above heroku.yml
replaces Procfile
.) And if I was using a buildpack I could use Procfile
but the docker daemon wouldn't be running.....
I tried defining a VOLUME
within the Dockerfile
and the problem persists. Furthermore a heroku article says "Volume mounting is not supported. The filesystem of the dyno is ephemeral."
On Heroku it is possible to run a docker image. What I am struggling at is running a docker in docker image.
Running a docker in docker image works fine on my VPS by mounting /var/run/docker.sock
but this cannot(?) be done on Heroku.
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.