-
Notifications
You must be signed in to change notification settings - Fork 190
Conversation
We should reuse the docker client's code for attaching to containers, rather than re-implementing it - it's a really complex process. |
I agree. Maybe I'll take a look at the docker client once I have some more time on my hand, for now we'll just keep it line by line. |
d72e8de
to
04bae5c
Compare
I revised all my commits and squashed them. Now the only thing I would like to improve is to really attach the container instead of just printing the log output. As @aanand mentioned, I'm going to try and reuse docker client code for this. |
@aanand Do you think it would make sense to essentially instantiate the docker cli and call the attach command? |
@flower-pot Yeah, essentially, though instantiating a CLI object is going to be ugly. It might be worth trying to extract that code so it's more reusable and submitting it as a PR to docker/docker. |
I agree. I'm going to take a look at how we can do that. The thing is, the attach command heavily relies on the |
@flower-pot I agree the CLI functionality should be pulled out. It would nice if we could find out what the status of moby/moby#15188 is. Basically there was supposed to be an effort to refactor a lot of the CLI code. I've been down this path before with other projects I've written and agree that instantiating the docker CLI is a nightmare. I think the correct first steps would be to figure out how to refactor the code in docker/docker to put the attach logic we need into a reusable pkg. It's just all the dirty TTY handling that we need. It can probably be encapsulated pretty well. |
Do you think the core team is going to take care of that? It seems pretty time consuming and I'm probably not the right guy to tackle this as I'm not very familiar with the docker codebase. |
Fixes docker#45 Signed-off-by: Josh Curl <[email protected]>
0f7763e
to
e75a461
Compare
mimicing the docker-compose run command in form of $ libcompose <service> <command> Signed-off-by: Frederic Branczyk <[email protected]>
Alright ported to the new dockerclient and now using its attach functionality. What do you think? I'm not entirely sure how to test this though. |
@flower-pot Sorry for the late review. Thanks for the PR, few consideration/comments :
I'll take a look at the code too 😉 |
Here is swarm's hijack implementation: https://github.com/docker/swarm/blob/894d1abd639eedb8234caf63fbc458a6791563bb/api/utils.go#L133 It's a bit cleaner. |
It's a little different because it's proxying, but probably useful. |
@vdemeester no problem, I haven't had time to revise it either. I think I had the problem that when opening stdin that the stream would never close therefore the execution never ended. But I have to take another look to make sure that's the case. |
@flower-pot still willing (or having time) to work on that ? |
I don't really have the time for it right now. If you don't want to use my changes you can close the PR. |
@flower-pot ok, I'm gonna carry it then 😉, keeping your commit and iterate on it 👍 Thanks for the hard work so far, really appreciated 🎅 |
@vdemeester Glad I could help :) |
Carrying in #133. |
Mimicking the docker-compose run command in form of
Signed-off-by: Frederic Branczyk [email protected]