-
Notifications
You must be signed in to change notification settings - Fork 608
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 executing into a task #1895
Comments
I'm not sure I understand the use case. I could see the point of |
@stevvooe for me, the use case is exactly the same as IMO it'd be very useful to be able to |
@hairyhenderson You can already I am not sure if this works, but it would be good if we could get to something like this:
Ideally, we'd like to automate this, but if you need to debug, this may help as a workaround, as long as the node names will resolve with ssh. |
That's exactly my point 🙂 The problem with your discover-node-then-ssh approach (which I do use on occasion) is that it presumes the host is reachable via SSH. There's no strict requirement for SSH to be available on swarm workers otherwise, so that's where some sort of I have no pressing requirement for this right now, but I hope this helps convince you that this is a legitimate use-case 🙂 |
This is just a suggested possible workaround and basically what needs to be built it. |
+1 |
+1 docker service exec |
I would love to see this working, especially now that 17.05.0-ce has In the meantime, check out this swarm-exec tool on github or use the ready container. Essentially, it provides the equivalent of the desired
For details, how it works and current limitations, see the project on github |
I too have a use case for this. I have a swarm (via Docker Cloud) that I use to deploy feature branches too using a CI server. I need a way to trigger some cleanup tasks that can only be ran from inside the container when a branch is deleted. My flow looks like this: Delete Branch -> Github Webhook -> Cleanup CI Job Executed -> docker service exec '.bin/perform-cleanup.sh' This is just my use case, but I'm certain there will be increasingly more of solid use cases for this feature. |
I want to address moby#1895 - Please beaware that this is just an experiment to get my hands dirty with the codebase and to understand how things works. At the current stage this basically is a gRPC service on the managers that connects the client to the client to the container executing the task of a specific service. It does not have TTYs. Feedback and What I need to go on: - I need some advice in designing this and if possible code review. - Since this is just a PoC I'm not yet writing tests, this is just something I need to understand a codebase where I'm not even that familiar to do TDD. - There are probably, I already see some of them contexts that are not closed. Try it: swarmctl service exec <service-id> (Yes I know that one expects to have `sh`) in the end or something like that. It's too early Signed-off-by: Lorenzo Fontana <lo@linux.com>
I want to address moby#1895 - Please beaware that this is just an experiment to get my hands dirty with the codebase and to understand how things works. At the current stage this basically is a gRPC service on the managers that connects the client to the client to the container executing the task of a specific service. It does not have TTYs. Feedback and What I need to go on: - I need some advice in designing this and if possible code review. - Since this is just a PoC I'm not yet writing tests, this is just something I need to understand a codebase where I'm not even that familiar to do TDD. - There are probably, I already see some of them contexts that are not closed. Try it: swarmctl service exec <service-id> (Yes I know that one expects to have `sh`) in the end or something like that. It's too early Signed-off-by: Lorenzo Fontana <lo@linux.com>
As a multiple tasks/containers can belong to one service, it would be more explicit to have a With having That doesn't matter? Randomly? Ok, if it will defined and designed like this, no problem. //edited: |
I'd be happy with |
I tend to agree that a random container would be fine. I need this to run things like crons and cleanup scripts before teardown, so any of the containers would suffice. Alternatively, you could pass one of the IDs of the running processes that show up when running |
just wrote a workaround through ssh and bash for that. Maybe it is helpful for somebody. |
Thanks @rdxmb I make a less sophisticated but very similar one a few days ago ;-) |
Hmm... I would like to see
and |
As I said here, the simpliest command I found to SERVICE_JSON=$(ssh $SWARM_MANAGER_HOST "docker service ps $SERVICE_NAME --no-trunc --format '{{ json . }}' -f desired-state=running")
ssh -t $(echo $SERVICE_JSON | jq -r '.Node') "docker exec -it $(echo $SERVICE_JSON | jq -r '.Name').$(echo $SERVICE_JSON | jq -r '.ID') bash" This asserts that you have ssh access to This also asserts that you have alias jq="python3 -c 'import sys, json; print(json.load(sys.stdin)[sys.argv[2].partition(\".\")[-1]])'" |
nothing simple about that @anthony-o , maybe from a sysadmin's perspective is simple enough but for developers not so much it would be great to have |
Just to add my 2 cents here. Right now I think arguably the best way to achieve this behaviour without changing moby/swarmkit is described here. I think if this were to be added to moby/swarmkit, the barrier between moby/moby and moby/swarmkit needs to be torn down to some extent. I feel like a swarmkit native way to access the docker api of other nodes in the cluster would allow for quite a lot of useful features added in either docker cli plugins or the docker cli itself. So rather than add a specific usecase to moby/swarmkit to exec into a service I think adding a more generic way could be a better solution? WDYT @dperny @neersighted @thaJeztah ? |
Hi, I just started working on creating a bash script that would make working with services in stacks on Docker Swarm easier. You can find it here: https://github.com/snth/docker-stack At the moment it makes exec'ing into a container and fetching the logs easier. I also want to add easier deployments that take environment variable substitutions into account like in docker-compose. LMK if it works for you or if you encounter any problems. |
Similar to
docker exec
, swarmkit should provide a way to execute commands inside a task, mostly for debugging purposes.The text was updated successfully, but these errors were encountered: