-
Notifications
You must be signed in to change notification settings - Fork 604
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 communicating with Docker over TCP #1
Comments
+1 Was just trying to achieve the same thing to test this thing out Communicating via TCP should not be required, mounting
Note that mounting docker.sock inside a container at I tried to change those lines and re-build docker-gen but couldn't get it to work. Only spent a couple of minutes so maybe it's just my lack of go-experience or a misconfiguration of the docker-gen parameters. @jwilder any chance on providing a Dockerized nginx proxy on index.docker.io? (preferably a 'trusted build') I like the simplicity of your software for simple development stuff (compared to more advanced systems like skydock etc). |
@ryfow I agree. The hard-coded unix domain socket is not ideal. |
@thaJeztah I'll look into getting docker-gen to run as a container. I have not tried that since I usually just run it on the host. An trusted build would be convenient though. |
@jwilder thanks a lot in advance! Now that I got the 'hang' of docker, I'd like keep my host clean, especially when testing new software :) |
I pushed some changes to master that add support for DOCKER_HOST as well as a new -endpoint flag via the command-line. The format is tcp://127.0.0.1:4243 or unix:///var/run/docker.sock. |
As far as I can tell the -endpoint flag will always ignored:
|
@cer You're right. Should be fixed now. |
@thaJeztah Created a trusted build: https://index.docker.io/u/jwilder/nginx-proxy/ Can you give it a try? |
This works really well! |
Works for me. |
@jwilder Not really sure what the problem is on my side; I'm running a container that exposes two ports (22 and 80) nginx-proxy tries to use port 22 (i.e. the 49xxx port that is assigned for port 22) as the upstream port. If I don't expose port 22, nginx-proxy doesn't pick-up the port and tries to use When exposing both port 22 and 80:
Which is to be expected, since this is the SSH port. If I only expose port 80;
And this is the configuration that was generated;
_Note:_ Replaced the actual domain-name with 'somedomainname.tld'. I'm using a '.xip.io' domain-name for testing, e.g. something.123.123.123.123.xip.io, but don't think this is related |
@thaJeztah I'll see if I can reproduce that. My guess is that the template is just assuming one port is exposed and this line: https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl#L5 is just picking the first address. |
@jwilder that was what I was thinking. Therefore tried to only expose port 80, in which case it completely stripped the port from the configuration, which was weird. |
Wouldn't it be better to provide a list of ports to docker-gen that are suppose to be exposed and then have docker-gen look up the exposed host port and then use that instead of trying to use all ports all the time? |
Yeah. That's sounds like a better idea. |
Basically, the proxy only needs to look for port 80 since it's used for web, unless a container contains two web-services on different ports? |
Not all apps use port 80 inside the container, most of the time in my experience they use different ports. I use everything from port 3012, to 8000, to 8080, etc ... No assumption should be made, a config option is best IMO. |
Agreed that it may be configurable. (However, using port 8080 etc most of the time is a workaround for port 80 already being in use?). If each container uses a different exposed port for web-traffic, nginx-proxy will need another env-variable per container to specify which port it should pick. |
Agreed. I think that is the best approach. |
..but 80 should be the default if no port is specified 😄 |
I think that is a reasonable assumption. |
How about this?
The first item keeps the config simple so existing users don't need to go back and add a VIRTUAL_PORT env variable. If a container publishes port 8080 and it's the only published port, it'll be used. Second item provides a way to specify which port to proxy to if your container publishes multiple ports. Third item seems like a reasonable default if multiple ports are published by a VIRTUAL_PORT env is not set. Also, just to clarify, I say published vs exposed because the containers need to be started w/ -p/-P to publish their exposed ports to the host. |
Looks good to me Although; On second thought (sorry!) containers without |
I've updated nginx-proxy to address the multiple port issue. Closing this since this issue is in docker-gen and originally about DOCKER_HOST. |
Fix @NickBolles restart feature building and Alpine bin compilation flag
I'm trying to set up the nginx reverse proxy as a docker container.
To do that, it'd be nice if docker-gen supported the DOCKER_HOST environment variable or a command-line parameter specifying how to communicate with Docker.
The text was updated successfully, but these errors were encountered: