Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple DOCKER_HOST? #94

Closed
viranch opened this issue Jun 21, 2015 · 8 comments

Comments

Projects
None yet
4 participants
@viranch
Copy link
Contributor

commented Jun 21, 2015

It'd be really convenient if docker-gen could support multiple (comma-separated?) values in DOCKER_HOST environment variable to be able to cleanly generate load balancer configs in a setup where backends are on different hosts.

Currently https://github.com/jwilder/docker-register & https://github.com/jwilder/docker-discover kinda do the trick but has some limitations:

  1. No SPDY support in HAProxy (which could be a deal breaker for many production systems).
  2. There is no way to access more properties of remote containers unless docker-register somehow adds these keys in etcd.

I am currently working on the following forks to overcome above limitations, but I'm already feeling dirty now:

  1. docker-register that registers all container ENVs with etcd
  2. docker-discover that replaces HAProxy with Nginx using VIRTUAL_HOST from ENVs in etcd and nginx template from https://github.com/jwilder/nginx-proxy

However, if we can add support for multiple DOCKER_HOSTs, life will be super easy; I can just use jwilder/nginx-proxy without having to do etcd+register+discover.

PS: I'd rather implement this feature then do the 2 forks described above. I'd love second opinion on the idea before I can start working.

@opyate

This comment has been minimized.

Copy link

commented Jun 25, 2015

👍 Or even support Docker Swarm?

I'm currently on Tutum where this limitation is overcome with something like https://github.com/madwire/tutum-nginx-proxy which uses Tutum's internal discovery API. My problems with this are:

  • in dev, I don't have a Tutum API
  • in prod, I don't really want to rely on a proprietary API, and would prefer a "pure" Docker solution
  • tutum-nginx-proxy makes for a huge image, because Ruby

UPDATE
I'll do an experiment and report back here: it all depends if the API exposed by a single host is the same as Swarm's.

UPDATE 2

From https://docs.docker.com/swarm/

Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.

UPDATE 3

One of the reference docker-gen use-cases - nginx-proxy - has a related issue: jwilder/nginx-proxy/issues/97

@md5

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2015

@opyate docker-gen already supports Swarm. See here: #71

@md5

This comment has been minimized.

Copy link
Contributor

commented Jun 25, 2015

Also, have a look at the blog post linked from this comment: #68 (comment)

@viranch

This comment has been minimized.

Copy link
Contributor Author

commented Jun 30, 2015

The Docker Swarm approach is a good idea. But it doesn't fully work with docker-gen when DOCKER_HOST is set to Swarm manager, because of a bug~~(?) in swarm (docker/swarm#1006)~~ in go's docker client library (samalba/dockerclient#126).

Essentially docker-gen listens for container die/start/stop events. When a container is restarted, docker generates 3 die+start+restart events, first 2 of which are acted upon by docker-gen. But swarm manager generates 3 events all with status restart only, hence getting ignored by docker-gen.

Quick fix might be to include restart in the container events listener in docker-gen.

Also, it might be better to include HostIP in the Address struct to ease the lookup of Host's IP if an app does not want to use container's IP.

@viranch

This comment has been minimized.

Copy link
Contributor Author

commented Jul 4, 2015

But swarm manager generates 3 events all with status restart only

This is now fixed by samalba/dockerclient#126

Also, it might be better to include HostIP in the Address struct to ease the lookup of Host's IP

This also I see is already done in #86

I guess docker-gen can now connect to Swarm to listen for containers on multiple docker engines/hosts.

@viranch viranch closed this Jul 4, 2015

@md5

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2015

This is now fixed by samalba/dockerclient#126

That won't help here since docker-gen uses fsouza/go-dockerclient, not samalba/dockerclient.

@md5

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2015

Oh, I see (after reading docker/swarm#1006). Swarm itself is using samalba/dockerclient, so this will be fixed in a newer version of Swarm.

@ldshi

This comment has been minimized.

Copy link

commented Nov 5, 2016

@md5 sorry, so what is the conclusion? set the DOCKER_HOST with the initial docker swarm master/manager node info, but in swarm mode, the master/manager node is always changing, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.