Nomad with Multi-container apps

812 views
Skip to first unread message

Wesley Staples

unread,
Aug 2, 2016, 4:47:31 PM8/2/16
to Nomad

I’m thinking through a development environment that uses docker. I’m using the project called laradock that creates multiple containers (one for php, one for nginx and a data volume for the source code). In the docker compose file I’m using the “links” attribute to tie them all together. I’m suddenly realizing that because it has more than 1 container I’m not sure how to deploy it. What would my options be for deploying this app with nomad?

I a dev setup consisting of 3 nomad servers and 3 workers. The servers have consul and vault. I was planning to use fabio for load balancing but nothing is final yet.


Option 1:

Rebuild the app as a single container. If this is the case I would not use laradock and have a single container for development as well to ensure consistency. I have to admit though simply swapping out the php5 container for php7 is pretty cool though. More of a docker question but is there a way to “squash” multiple containers into one with docker? (I haven’t seen one)


Option 2:

Publish each container as a service. using task groups I could publish the php-fpm container with a consul service declaration of ‘<project_name>_php_fpm’. Then change the nginx upstream config to look for ‘<project_name>_php_fpm.service.consul:9000’ instead of an ip address. If each container lands on a different box and they are all communicating over the network that seems like it would be inefficient or is this just normally how it works? When I publish my next app it will probably use the same php and nginx containers so how would I reuse them (or should I)?

If I choose this option it would seem like I would need a php-fpm container for every app I deploy (as the pool settings may not be correct for more than 1 website).

I would also need to find a way to emulate consul behavior in development. For example if I changed the nginx box to look for the upstream of testapp_phpfpm.service.conusl I would have to have a way of publishing this information in our local laradock environment. The goal being that running docker-compose would make the same consul information available that nomad / production boxes will find.


Other challenges:

Most of our projects have a .env file that contains environment specific settings. I could use nomad’s ENV directive. or would it be better to use something like consul-template? I’m curios about consul-template because it was my understanding the app code should become immutable once inside the container.

Chris Stevens

unread,
Aug 3, 2016, 12:48:18 AM8/3/16
to Nomad
Hey Wes,

I am actually waiting right now on docker-compose to finish building on what sounds like a similar setup. php-fpm (7 on alpine), nginx, cakephp, consul, vault, etc.

Once I get this working, I am immediately porting it over to Nomad. Haven't decided if I'll run nomad for development yet, but am interested in anybody that is.

I am not using links in docker-compose right now. I did have separate nginx and php-fpm containers as a PoC, but want to be Nomad-compatible and rely on consul for linking services.

Similar to what you describe, I am currently adding nginx and supervisor *into* the php-fpm container that will also contain my app code. This feels like the correct scope for a deployable unit. I can use unix sockets for fpm and nginx communications and (hopefully) consul for everything else.

Hope that helps a bit. I'll follow the convo here and chime in later.

- Chris
Reply all
Reply to author
Forward
0 new messages