Docker – Automatically add new vhosts to docker nginx container

docker

I'm very, very new to docker.

Main concepts of docker, and microsrvices are quite clear for me, same with docker usage. I know how to manage containers, create images etc.

The problem that I face now, is working with many containers, and dynamically update services configuration inside of them.

For example, it's very easy to create Dockerfile to launch jenkins, or to launch nginx.

But how to automatically add new virtual hosts in nginx container to pass traffic to jenkins container, and then to newly created nagios container, and then to puppet dashboard container.

I believe that manually adding new virtual hosts to nginx is very 'old fashioned'. I also feel that using puppet to configure nginx docker container is also very old fashioned. I use puppet to deploy docker images on docker host, but I don't use puppet to manage content of containers.

I read about consul/etcd – and the whole idea of service discovery, but it looks little 'to much' for such simple problem.

I'll be glad to read about good solutions from more experienced docker users. How do you dynamically configure your services configuration inside of docker?

Best Answer

You can use a reverse proxy that uses auto-generated config files based on docker introspection of the containers.

Here is an image implementing precisely that: https://github.com/jwilder/nginx-proxy