Skip to content

Commit

Permalink
Merge pull request moby#17534 from Microsoft/10662-filterhyperv
Browse files Browse the repository at this point in the history
Windows: Add isolation to ps filter
  • Loading branch information
cpuguy83 committed Nov 5, 2015
2 parents 3c6962f + 9c58141 commit 9465d6e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions daemon/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ func includeContainerInList(container *Container, ctx *listContext) iterationAct
return excludeContainer
}

// Do not include container if the isolation mode doesn't match
if excludeContainer == excludeByIsolation(container, ctx) {
return excludeContainer
}

// Do not include container if it's in the list before the filter container.
// Set the filter container to nil to include the rest of containers after this one.
if ctx.beforeContainer != nil {
Expand Down
9 changes: 9 additions & 0 deletions daemon/list_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// +build linux freebsd

package daemon

// excludeByIsolation is a platform specific helper function to support PS
// filtering by Isolation. This is a Windows-only concept, so is a no-op on Unix.
func excludeByIsolation(container *Container, ctx *listContext) iterationAction {
return includeContainer
}
16 changes: 16 additions & 0 deletions daemon/list_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package daemon

import "strings"

// excludeByIsolation is a platform specific helper function to support PS
// filtering by Isolation. This is a Windows-only concept, so is a no-op on Unix.
func excludeByIsolation(container *Container, ctx *listContext) iterationAction {
i := strings.ToLower(string(container.hostConfig.Isolation))
if i == "" {
i = "default"
}
if !ctx.filters.Match("isolation", i) {
return excludeContainer
}
return includeContainer
}
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ This section lists each version from latest to oldest. Each listing includes a

[Docker Remote API v1.22](docker_remote_api_v1.22.md) documentation

* `GET /containers/json` supports filter `isolation` on Windows.

### v1.21 API changes

Expand Down
1 change: 1 addition & 0 deletions docs/reference/api/docker_remote_api_v1.22.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Query Parameters:
- `exited=<int>`; -- containers with exit code of `<int>` ;
- `status=`(`created`|`restarting`|`running`|`paused`|`exited`)
- `label=key` or `label="key=value"` of a container label
- `isolation=`(`default`|`hyperv`) (Windows daemon only)

Status Codes:

Expand Down
1 change: 1 addition & 0 deletions docs/reference/commandline/ps.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The currently supported filters are:
* exited (int - the code of exited containers. Only useful with `--all`)
* status (created|restarting|running|paused|exited)
* ancestor (`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - filters containers that were created from the given image or a descendant.
* isolation (default|hyperv) (Windows daemon only)


#### Label
Expand Down

0 comments on commit 9465d6e

Please sign in to comment.