3 ms·
I would very much like to use Docker/containers to provision and deploy my software stacks on a beefy server I have. The ideal for me would be a whole VM in a c
by StavrosK 13y ago
I would very much like to use Docker/containers to provision and deploy my software stacks on a beefy server I have. The ideal for me would be a whole VM in a container (nginx/uwsgi/redis/postgres/etc), but Docker can't currently do that (it only runs a single process).
Is there a practical/good way to easily do what I want, with Docker or another tool?
- alexlarsson 13y agoThe process docker runs in the container can be /sbin/init, which spawns an entire OS. Its just not how its normally used.
- StavrosK 13y agoHmm, I guess that could do it. I wonder if I can run the upstart daemon first to have it start my services. That would be ideal.
- yackob03 13y agoCorrect me if I'm wrong, but as far as I know Docker actually does run a binary called /sbin/init, it's just that they've replaced it in the base images with something that is more suited for fast startup times and running of a single process. Setting the Docker start command to init will probably not accomplish what you want.
- shykes 13y agoThat was true in earlier versions of Docker, but has been fixed. alexlarsson is correct :)
- asdfaoeu 13y agoIt's not really limited to one process you can just run a bash script to start everything or ideally some daemon management program.
- andreypopp 13y agoDid you try Dokku[1] (git hook + Heroku buildpacks + Docker)? You can build/deploy several apps to docker containers using git push. It has PostgreSQL plugin and exposes your app via nginx. Of course it wouldn't be 100% usable as-is, but its codebase is very hackable — around 150LOC. For example I've forked it to built a μPaaS[2] — it has out-of-the-box integration with upstart (for supervision and logging) and replaced Heroku buildpacks with the ability to define stack in Dockerfile (which is much simpler). [1]: https://github.com/progrium/dokku https://github.com/progrium/dokku [2]: https://github.com/andreypopp/upaas https://github.com/andreypopp/upaas
- StavrosK 13y agoThe only reason I haven't tried it is because I've never really used Heroku, but I'll give it a shot now, thanks.
- steeve 13y agoI actually spawn multiple processes thanks to supervisord, which also restarts them if needed. See https://github.com/steeve/docker-lemp https://github.com/steeve/docker-lemp
- StavrosK 13y agoThat's my preference as well, I just prefer upstart to supervisord. Does anyone know how to start it offhand? It's probably just as easy as running the upstart daemon. EDIT: Well, supervisord looks straightforward, and you only need a single config file for everything. You have swayed me, thank you for that. This will do perfectly, I will try it today.
- windexh8er 13y agoThere's a great example here of a well done Dockerfile and implementation using supervisor.
- windexh8er 13y agoCan't edit on mobile, but here's the example referenced: https://github.com/dotcloud/collectd-graphite?files=1 https://github.com/dotcloud/collectd-graphite?files=1
- StavrosK 13y agoFantastic, thank you. This is the approach I'll follow, and that looks very well structured.
- huxley 13y agoThis might be interesting too: Pipework https://github.com/jpetazzo/pipework https://github.com/jpetazzo/pipework Essentially it lets you create private networks between containers which could each run its own service (one for Postgres, one for Redis, etc).
- jasonkolb 13y agoJust create a bootstrap shell script that can be run on any machine. At a high level here's what mine does: 1) Install git 2) Clone a repo with all of the dockerfiles in it (each dockerfile corresponds to a container) 3) Install Docker 4) Start containers using the previously-mentioned scripts The advantage to using a shell script for this is that you can start it manually or via an automated system. All you need is the bootstrap script and you can start your app on any machine. Well, apart from the distributions the post mentions I guess.
- StavrosK 13y agoThis is what I want the Dockerfile to do for me. For some reason, I don't really want to manage all the different components' containers myself (it's added complexity).
- jaytaylor 13y agoYou should checkout ShipBuilder [1][2]. ShipBuilder is a freely available open-source self-hosted PaaS -- it aims to be an open clone of Heroku. It uses Go, LXC, and HAProxy. [1] https://github.com/sendhub/shipbuilder https://github.com/sendhub/shipbuilder [2] http://shipbuilder.io http://shipbuilder.io Disclaimer: I am a committer on the project
- StavrosK 13y agoHmm, I had a look, but it's very light on documentation. So light, that it didn't really explain what the advantage is, or why I should try it, or how it works. (I tend to tune out the "open-source PaaS" offering because it's consistently been something too hard/heavy/weird to set up).