Skip to content

Accept filters in list containers#262

Merged
marcuslinke merged 3 commits intodocker-java:masterfrom
carlossg:list-containers-filters
Jul 11, 2015
Merged

Accept filters in list containers#262
marcuslinke merged 3 commits intodocker-java:masterfrom
carlossg:list-containers-filters

Conversation

@carlossg
Copy link
Copy Markdown
Contributor

@carlossg carlossg commented Jul 7, 2015

PR on top of #260, to test with container labels

@carlossg
Copy link
Copy Markdown
Contributor Author

carlossg commented Jul 7, 2015

The filters query param in Docker API is a pita, it is a json representation of the filters (Map<String, String[]>) but needs to be URL encoded for jersey to work, or it barfs on the curly braces { because it thinks it is a jersey template.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific test doesn't work in my local test env (docker api 1.18). The is no filtering when passing label filter without 'label' keyword.

@marcuslinke
Copy link
Copy Markdown
Contributor

Seems the label filtering is somehow broken with docker 1.7.0/1.19 also. It finds containers that haven't a label at all. An appropriate log example:

23:08:38.856 DEBUG c.g.d.jaxrs.DockerCmdExecFactoryImpl - 29 * Sending client request on thread main
29 > GET https://192.168.59.103:2376/containers/json?filters=%7B%22listcontainertest%22:%5B%22docker-java%22%5D%7D&all=1&size=0
29 > Accept: application/json

23:08:39.121 DEBUG c.g.d.jaxrs.DockerCmdExecFactoryImpl - 30 * Client response received on thread main
30 < 200
30 < Content-Length: 538
30 < Content-Type: application/json
30 < Date: Thu, 09 Jul 2015 21:08:37 GMT
[{"Id":"c10fa26069f9421daec0ad15c5e02626e781a7ce48f6293e90b6b033b779ec75","Names":["/gloomy_almeida"],"Image":"busybox","Command":"echo","Created":1436476116,"Ports":[],"Labels":{"listcontainertest":"docker-java"},"Status":"Exited (0) Less than a second ago"},{"Id":"f993b8837846a66fcb590c40bc0b511efaeff036870a12ad13c0f6d8828dce09","Names":["/prickly_payne"],"Image":"ee151a08220c9dee6f21dc1db29e53a09d11fa5dac21f8ec0fb46fea8c1f9bd8","Command":"./cmd.sh","Created":1436475851,"Ports":[],"Labels":{},"Status":"Exited (0) 4 minutes ago"}]

@carlossg
Copy link
Copy Markdown
Contributor Author

Yes, seems I misunderstood the docs. I have debugged the daemon logs and updated the implementation to work with withLabel("test") or withLabel("test=docker-java")
Also improved the test

@marcuslinke marcuslinke merged commit 769f176 into docker-java:master Jul 11, 2015
@marcuslinke
Copy link
Copy Markdown
Contributor

@carlossg Thanks for your contribution!

@carlossg carlossg deleted the list-containers-filters branch July 13, 2015 07:23
calavera pushed a commit to calavera/docker that referenced this pull request Jul 25, 2015
Based on the list containers with filters options it would seem that filtering containers with label `test=docker-java` could be done with `{"test":["docker-java"]}` which doesn't work

The options that work are `{"label":["test"]}` and `{"label":["test=docker-java"]}`

As seen in docker-java/docker-java#262

Signed-off-by: Carlos Sanchez <[email protected]>
tiborvass pushed a commit to tiborvass/docker that referenced this pull request Jul 27, 2015
Based on the list containers with filters options it would seem that filtering containers with label `test=docker-java` could be done with `{"test":["docker-java"]}` which doesn't work

The options that work are `{"label":["test"]}` and `{"label":["test=docker-java"]}`

As seen in docker-java/docker-java#262

Signed-off-by: Carlos Sanchez <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants