Skip to content
New issue

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

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

Already on GitHub? # to your account

Optimize by querying by ID #57

Open
bjwschaap opened this issue Jul 20, 2018 · 1 comment
Open

Optimize by querying by ID #57

bjwschaap opened this issue Jul 20, 2018 · 1 comment

Comments

@bjwschaap
Copy link

bjwschaap commented Jul 20, 2018

You don't need to fetch and loop through all services in the Swarm @

for _, service := range services {

Instead you can add a filter, and fetch the required service directly. E.g.:

serviceFilter := filters.NewArgs()
serviceFilter.Add("id", serviceId)
services, err := dockerClient.ServiceList(ctx, types.ServiceListOptions{Filters: serviceFilter})

Also see: https://docs.docker.com/engine/reference/commandline/service_ls/#filtering

@gianarb
Copy link
Owner

gianarb commented Jul 20, 2018

This is a good catch @bjwschaap thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants