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

Docker CLI hangs when launching PWD containers in non detached mode #78

Closed
marcosnils opened this issue Jan 6, 2017 · 17 comments
Closed

Comments

@marcosnils
Copy link
Contributor

If you point your docker cli using DOCKER_HOST to a pwd daemon and try to run a non detached container, the CLI will hang and the container will be left in "Created" state

Check play-with-docker/docker-machine-driver-pwd#1 for more info

@marcosnils
Copy link
Contributor Author

marcosnils commented Jan 11, 2017

Found the reason. When creating a container the CLI tries to hijack the connection by telling the server that it'll upgrade the connection to TCP to stream the container output:

https://github.com/docker/docker/blob/d8d33148d809ec97794bbd492617b1be677cf820/client/hijack.go#L36-L80

PWD doesn't support TCP proxying ATM, so I'm not sure how/if we should handle this.

any ideas @jpetazzo @xetorthio @alexellis @akalipetis @so0k ?

@jpetazzo
Copy link
Contributor

Ideas:

  • support TCP proxying (doh!)
  • have each DinD instance expose port 2376, and give that port number when specifying DOCKER_HOST (requires SSL certs)
  • use ngrok in TCP mode (maybe?)

@marcosnils
Copy link
Contributor Author

support TCP proxying (doh!)

Yes, but how?. We can't do TCP/IP reverse proxy as we have no way to know which instance the client is trying to talk to as it's only ip:port.

have each DinD instance expose port 2376, and give that port number when specifying DOCKER_HOST (requires SSL certs)

Not sure how this helps with the hang thing. Whenever the CLI tries to upgrade the connection to TCP, it will still fail, right?

use ngrok in TCP mode (maybe?)

Yes, but this won't work for PWD machine driver :(. As ngrok address will differ from the original endpoint.

@xetorthio
Copy link
Contributor

xetorthio commented Jan 25, 2017 via email

@marcosnils
Copy link
Contributor Author

We could use a prefixed port for each DinD as a way to handle TCP proxying
to the docker daemon

so basically, each time you create an instance (dind) you allocate a port on the host that will serve as TCP proxy?. But that will require the instance to have several daemon ports wide open right?. If this is the case we'll have to restrict daemons to SSL which will invalidate the ability to set DOCKER_HOST manually to control PWD daemons.

@xetorthio
Copy link
Contributor

xetorthio commented Jan 25, 2017 via email

@marcosnils
Copy link
Contributor Author

Why this would restrict daemons to SSL?

Because there are hundreds of bots out there looking for open daemons to mess with the system. Right now it's "more" to do because it'd have to guess the URL of the instance to access. But if we do TCP reverse proxy through the host ip: it'd be super easy to detect and exploit.

@xetorthio
Copy link
Contributor

xetorthio commented Jan 25, 2017 via email

@marcosnils
Copy link
Contributor Author

But to be able to set your host manually you'd have to set a few extra
parameters, as we would use SSL.
Doesn't seem like a big price to pay, right?

Well.. it's not that easy. You'd need to get the certificates somehow to make it work manually. When using machine these are provided by machine itself.

@xetorthio
Copy link
Contributor

xetorthio commented Jan 25, 2017 via email

@marcosnils
Copy link
Contributor Author

marcosnils commented Jan 25, 2017

The play-with-docker website can give you a nice link to download the
certificates and even tell you how to configure your CLI to work with the
daemon.

It's not exactly how it works. The user needs to generate some certs and then make the CA (the server in this case) sign them. So "just downloading" them is not an option.

Still seems like a very corner case. My guess is that people will either
use play-with-docker web interface and/or docker-machine. Which means that
optimizing for these two is the right move

Agree. I propose to just drop the single CLI configuration for simplicity and security aspects and only allow docker-machine configurations.

@xetorthio
Copy link
Contributor

It's not exactly how it works. The user needs to generate some certs and then make the CA (the server in this case) sign them. So "just downloading" them is not an option.

That depends. In our case client validates that the server uses a valid certificate signed by some known and trusted CA. So by default the DinD, when created, can offer a certificate and the CA for the client to use. This would solve the manual CLI configuration.

When using docker-machine, those keys are overwritten by the ones machine sends (this is already how it works now).

Which means that all scenarios would be possible with a very small change.

@marcosnils
Copy link
Contributor Author

So by default the DinD, when created, can offer a certificate and the CA for the client to use. This would solve the manual CLI configuration.

Right. Not sure if it makes a lot of sense though. Now the certs will depend on each instance you create instead of downloading them directly from the PWD site.

I guess my vote goes for just ignore this use-case and focus on machine + tcp ssl proxy for the moment.

@xetorthio
Copy link
Contributor

Now the certs will depend on each instance you create instead of downloading them directly from the PWD site.

Not sure I understand this. Can you explain this further?

@marcosnils
Copy link
Contributor Author

Seems like now it's not even possible to run detached containers. I think something changed in the daemon that's preventing this :(. @jpetazzo any hints?

@xetorthio
Copy link
Contributor

What we are going to do is to proxy tcp encapsulated in http. This will fix this issue and might also make http and websocket proxy totally useless. We'll try and report back soon!

@marcosnils
Copy link
Contributor Author

Fixed by 75f3c93 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants