2014-08-01 01:26:25 +04:00
|
|
|
package daemon
|
2014-07-30 06:04:39 +04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
2014-06-02 23:08:39 +04:00
|
|
|
"strconv"
|
2014-07-30 06:04:39 +04:00
|
|
|
"strings"
|
|
|
|
|
2015-08-20 10:57:15 +03:00
|
|
|
"github.com/Sirupsen/logrus"
|
2015-04-04 03:39:06 +03:00
|
|
|
"github.com/docker/docker/api/types"
|
2015-09-18 20:48:16 +03:00
|
|
|
derr "github.com/docker/docker/errors"
|
2015-10-15 23:09:30 +03:00
|
|
|
"github.com/docker/docker/graph"
|
2015-08-20 10:57:15 +03:00
|
|
|
"github.com/docker/docker/image"
|
2014-07-30 06:04:39 +04:00
|
|
|
"github.com/docker/docker/pkg/graphdb"
|
2015-06-30 19:41:01 +03:00
|
|
|
"github.com/docker/docker/pkg/nat"
|
2014-06-02 23:08:39 +04:00
|
|
|
"github.com/docker/docker/pkg/parsers/filters"
|
2014-07-30 06:04:39 +04:00
|
|
|
)
|
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// iterationAction represents possible outcomes happening during the container iteration.
|
|
|
|
type iterationAction int
|
|
|
|
|
|
|
|
// containerReducer represents a reducer for a container.
|
|
|
|
// Returns the object to serialize by the api.
|
2015-09-29 20:51:40 +03:00
|
|
|
type containerReducer func(*Container, *listContext) (*types.Container, error)
|
2015-08-26 11:16:53 +03:00
|
|
|
|
|
|
|
const (
|
|
|
|
// includeContainer is the action to include a container in the reducer.
|
|
|
|
includeContainer iterationAction = iota
|
|
|
|
// excludeContainer is the action to exclude a container in the reducer.
|
|
|
|
excludeContainer
|
|
|
|
// stopIteration is the action to stop iterating over the list of containers.
|
|
|
|
stopIteration
|
|
|
|
)
|
|
|
|
|
|
|
|
// errStopIteration makes the iterator to stop without returning an error.
|
|
|
|
var errStopIteration = errors.New("container list iteration stopped")
|
|
|
|
|
2014-08-01 01:26:25 +04:00
|
|
|
// List returns an array of all containers registered in the daemon.
|
2015-09-29 20:51:40 +03:00
|
|
|
func (daemon *Daemon) List() []*Container {
|
2014-08-01 01:26:25 +04:00
|
|
|
return daemon.containers.List()
|
|
|
|
}
|
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// ContainersConfig is the filtering specified by the user to iterate over containers.
|
2015-04-07 22:34:30 +03:00
|
|
|
type ContainersConfig struct {
|
2015-07-31 00:01:53 +03:00
|
|
|
// if true show all containers, otherwise only running containers.
|
|
|
|
All bool
|
|
|
|
// show all containers created after this container id
|
|
|
|
Since string
|
|
|
|
// show all containers created before this container id
|
|
|
|
Before string
|
|
|
|
// number of containers to return at most
|
|
|
|
Limit int
|
|
|
|
// if true include the sizes of the containers
|
|
|
|
Size bool
|
|
|
|
// return only containers that match filters
|
2015-04-07 22:34:30 +03:00
|
|
|
Filters string
|
|
|
|
}
|
2015-04-04 03:39:06 +03:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// listContext is the daemon generated filtering to iterate over containers.
|
|
|
|
// This is created based on the user specification.
|
|
|
|
type listContext struct {
|
|
|
|
// idx is the container iteration index for this context
|
|
|
|
idx int
|
|
|
|
// ancestorFilter tells whether it should check ancestors or not
|
|
|
|
ancestorFilter bool
|
|
|
|
// names is a list of container names to filter with
|
|
|
|
names map[string][]string
|
|
|
|
// images is a list of images to filter with
|
|
|
|
images map[string]bool
|
|
|
|
// filters is a collection of arguments to filter with, specified by the user
|
|
|
|
filters filters.Args
|
|
|
|
// exitAllowed is a list of exit codes allowed to filter with
|
|
|
|
exitAllowed []int
|
|
|
|
// beforeContainer is a filter to ignore containers that appear before the one given
|
|
|
|
beforeContainer *Container
|
|
|
|
// sinceContainer is a filter to stop the filtering when the iterator arrive to the given container
|
|
|
|
sinceContainer *Container
|
|
|
|
// ContainersConfig is the filters set by the user
|
|
|
|
*ContainersConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
// Containers returns the list of containers to show given the user's filtering.
|
2015-09-29 20:51:40 +03:00
|
|
|
func (daemon *Daemon) Containers(config *ContainersConfig) ([]*types.Container, error) {
|
|
|
|
return daemon.reduceContainers(config, daemon.transformContainer)
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// reduceContainer parses the user filtering and generates the list of containers to return based on a reducer.
|
2015-09-29 20:51:40 +03:00
|
|
|
func (daemon *Daemon) reduceContainers(config *ContainersConfig, reducer containerReducer) ([]*types.Container, error) {
|
2015-09-18 19:39:14 +03:00
|
|
|
containers := []*types.Container{}
|
2015-08-26 11:16:53 +03:00
|
|
|
|
2015-09-29 20:51:40 +03:00
|
|
|
ctx, err := daemon.foldFilter(config)
|
2015-08-26 11:16:53 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2015-09-29 20:51:40 +03:00
|
|
|
for _, container := range daemon.List() {
|
|
|
|
t, err := daemon.reducePsContainer(container, ctx, reducer)
|
2015-08-26 11:16:53 +03:00
|
|
|
if err != nil {
|
|
|
|
if err != errStopIteration {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if t != nil {
|
|
|
|
containers = append(containers, t)
|
2015-09-29 20:51:40 +03:00
|
|
|
ctx.idx++
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return containers, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// reducePsContainer is the basic representation for a container as expected by the ps command.
|
2015-09-29 20:51:40 +03:00
|
|
|
func (daemon *Daemon) reducePsContainer(container *Container, ctx *listContext, reducer containerReducer) (*types.Container, error) {
|
2015-08-26 11:16:53 +03:00
|
|
|
container.Lock()
|
|
|
|
defer container.Unlock()
|
2014-07-30 06:04:39 +04:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// filter containers to return
|
2015-09-29 20:51:40 +03:00
|
|
|
action := includeContainerInList(container, ctx)
|
2015-08-26 11:16:53 +03:00
|
|
|
switch action {
|
|
|
|
case excludeContainer:
|
|
|
|
return nil, nil
|
|
|
|
case stopIteration:
|
|
|
|
return nil, errStopIteration
|
|
|
|
}
|
|
|
|
|
|
|
|
// transform internal container struct into api structs
|
2015-09-29 20:51:40 +03:00
|
|
|
return reducer(container, ctx)
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// foldFilter generates the container filter based in the user's filtering options.
|
2015-09-29 20:51:40 +03:00
|
|
|
func (daemon *Daemon) foldFilter(config *ContainersConfig) (*listContext, error) {
|
2015-04-07 22:34:30 +03:00
|
|
|
psFilters, err := filters.FromParam(config.Filters)
|
2014-06-02 23:08:39 +04:00
|
|
|
if err != nil {
|
2015-04-07 22:34:30 +03:00
|
|
|
return nil, err
|
2014-06-02 23:08:39 +04:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
|
|
|
|
var filtExited []int
|
2014-06-02 23:08:39 +04:00
|
|
|
if i, ok := psFilters["exited"]; ok {
|
|
|
|
for _, value := range i {
|
|
|
|
code, err := strconv.Atoi(value)
|
|
|
|
if err != nil {
|
2015-04-07 22:34:30 +03:00
|
|
|
return nil, err
|
2014-06-02 23:08:39 +04:00
|
|
|
}
|
2015-03-26 04:40:23 +03:00
|
|
|
filtExited = append(filtExited, code)
|
2014-06-02 23:08:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-09 02:14:04 +03:00
|
|
|
if i, ok := psFilters["status"]; ok {
|
|
|
|
for _, value := range i {
|
2015-07-01 00:40:27 +03:00
|
|
|
if !isValidStateString(value) {
|
|
|
|
return nil, errors.New("Unrecognised filter value for status")
|
|
|
|
}
|
2015-10-15 14:04:13 +03:00
|
|
|
|
|
|
|
config.All = true
|
2015-01-09 02:14:04 +03:00
|
|
|
}
|
|
|
|
}
|
2015-08-20 10:57:15 +03:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
imagesFilter := map[string]bool{}
|
|
|
|
var ancestorFilter bool
|
2015-08-20 10:57:15 +03:00
|
|
|
if ancestors, ok := psFilters["ancestor"]; ok {
|
|
|
|
ancestorFilter = true
|
2015-09-29 20:51:40 +03:00
|
|
|
byParents := daemon.Graph().ByParent()
|
2015-08-20 10:57:15 +03:00
|
|
|
// The idea is to walk the graph down the most "efficient" way.
|
|
|
|
for _, ancestor := range ancestors {
|
|
|
|
// First, get the imageId of the ancestor filter (yay)
|
2015-10-02 00:51:36 +03:00
|
|
|
image, err := daemon.repositories.LookupImage(ancestor)
|
2015-08-20 10:57:15 +03:00
|
|
|
if err != nil {
|
|
|
|
logrus.Warnf("Error while looking up for image %v", ancestor)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if imagesFilter[ancestor] {
|
|
|
|
// Already seen this ancestor, skip it
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// Then walk down the graph and put the imageIds in imagesFilter
|
|
|
|
populateImageFilterByParents(imagesFilter, image.ID, byParents)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-02 23:54:27 +03:00
|
|
|
names := make(map[string][]string)
|
2015-07-31 00:01:53 +03:00
|
|
|
daemon.containerGraph().Walk("/", func(p string, e *graphdb.Entity) error {
|
2014-07-30 06:04:39 +04:00
|
|
|
names[e.ID()] = append(names[e.ID()], p)
|
|
|
|
return nil
|
2015-01-15 02:26:42 +03:00
|
|
|
}, 1)
|
2014-07-30 06:04:39 +04:00
|
|
|
|
2014-08-01 01:26:25 +04:00
|
|
|
var beforeCont, sinceCont *Container
|
2015-04-07 22:34:30 +03:00
|
|
|
if config.Before != "" {
|
2015-09-29 20:51:40 +03:00
|
|
|
beforeCont, err = daemon.Get(config.Before)
|
2014-12-17 02:06:35 +03:00
|
|
|
if err != nil {
|
2015-04-07 22:34:30 +03:00
|
|
|
return nil, err
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-07 22:34:30 +03:00
|
|
|
if config.Since != "" {
|
2015-09-29 20:51:40 +03:00
|
|
|
sinceCont, err = daemon.Get(config.Since)
|
2014-12-17 02:06:35 +03:00
|
|
|
if err != nil {
|
2015-04-07 22:34:30 +03:00
|
|
|
return nil, err
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
return &listContext{
|
|
|
|
filters: psFilters,
|
|
|
|
ancestorFilter: ancestorFilter,
|
|
|
|
names: names,
|
|
|
|
images: imagesFilter,
|
|
|
|
exitAllowed: filtExited,
|
|
|
|
beforeContainer: beforeCont,
|
|
|
|
sinceContainer: sinceCont,
|
|
|
|
ContainersConfig: config,
|
|
|
|
}, nil
|
|
|
|
}
|
2014-10-13 10:12:44 +04:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// includeContainerInList decides whether a containers should be include in the output or not based in the filter.
|
|
|
|
// It also decides if the iteration should be stopped or not.
|
|
|
|
func includeContainerInList(container *Container, ctx *listContext) iterationAction {
|
|
|
|
// Do not include container if it's stopped and we're not filters
|
|
|
|
if !container.Running && !ctx.All && ctx.Limit <= 0 && ctx.beforeContainer == nil && ctx.sinceContainer == nil {
|
|
|
|
return excludeContainer
|
|
|
|
}
|
2014-10-13 10:12:44 +04:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// Do not include container if the name doesn't match
|
|
|
|
if !ctx.filters.Match("name", container.Name) {
|
|
|
|
return excludeContainer
|
|
|
|
}
|
2015-01-07 03:04:10 +03:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// Do not include container if the id doesn't match
|
|
|
|
if !ctx.filters.Match("id", container.ID) {
|
|
|
|
return excludeContainer
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do not include container if any of the labels don't match
|
|
|
|
if !ctx.filters.MatchKVList("label", container.Config.Labels) {
|
|
|
|
return excludeContainer
|
|
|
|
}
|
|
|
|
|
2015-10-19 19:33:43 +03:00
|
|
|
// Do not include container if the isolation mode doesn't match
|
|
|
|
if excludeContainer == excludeByIsolation(container, ctx) {
|
|
|
|
return excludeContainer
|
|
|
|
}
|
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// 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 {
|
|
|
|
if container.ID == ctx.beforeContainer.ID {
|
|
|
|
ctx.beforeContainer = nil
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
return excludeContainer
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop iteration when the index is over the limit
|
|
|
|
if ctx.Limit > 0 && ctx.idx == ctx.Limit {
|
|
|
|
return stopIteration
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop interation when the container arrives to the filter container
|
|
|
|
if ctx.sinceContainer != nil {
|
|
|
|
if container.ID == ctx.sinceContainer.ID {
|
|
|
|
return stopIteration
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Do not include container if its exit code is not in the filter
|
|
|
|
if len(ctx.exitAllowed) > 0 {
|
|
|
|
shouldSkip := true
|
|
|
|
for _, code := range ctx.exitAllowed {
|
|
|
|
if code == container.ExitCode && !container.Running {
|
|
|
|
shouldSkip = false
|
|
|
|
break
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
if shouldSkip {
|
|
|
|
return excludeContainer
|
2014-06-02 23:08:39 +04:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
2014-10-13 10:12:44 +04:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// Do not include container if its status doesn't match the filter
|
|
|
|
if !ctx.filters.Match("status", container.State.StateString()) {
|
|
|
|
return excludeContainer
|
|
|
|
}
|
2015-08-20 10:57:15 +03:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
if ctx.ancestorFilter {
|
|
|
|
if len(ctx.images) == 0 {
|
|
|
|
return excludeContainer
|
2015-08-20 10:57:15 +03:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
if !ctx.images[container.ImageID] {
|
|
|
|
return excludeContainer
|
2015-04-04 03:39:06 +03:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
2015-05-01 04:13:18 +03:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
return includeContainer
|
|
|
|
}
|
2015-05-01 04:13:18 +03:00
|
|
|
|
2015-10-15 23:09:30 +03:00
|
|
|
func getImage(s *graph.TagStore, img, imgID string) (string, error) {
|
|
|
|
// both Image and ImageID is actually ids, nothing to guess
|
|
|
|
if strings.HasPrefix(imgID, img) {
|
|
|
|
return img, nil
|
|
|
|
}
|
|
|
|
id, err := s.GetID(img)
|
|
|
|
if err != nil {
|
|
|
|
if err == graph.ErrNameIsNotExist {
|
|
|
|
return imgID, nil
|
|
|
|
}
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
if id != imgID {
|
|
|
|
return imgID, nil
|
|
|
|
}
|
|
|
|
return img, nil
|
|
|
|
}
|
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
// transformContainer generates the container type expected by the docker ps command.
|
2015-09-29 20:51:40 +03:00
|
|
|
func (daemon *Daemon) transformContainer(container *Container, ctx *listContext) (*types.Container, error) {
|
2015-08-26 11:16:53 +03:00
|
|
|
newC := &types.Container{
|
2015-10-02 17:48:35 +03:00
|
|
|
ID: container.ID,
|
|
|
|
Names: ctx.names[container.ID],
|
|
|
|
ImageID: container.ImageID,
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
2015-10-02 23:54:27 +03:00
|
|
|
if newC.Names == nil {
|
|
|
|
// Dead containers will often have no name, so make sure the response isn't null
|
|
|
|
newC.Names = []string{}
|
|
|
|
}
|
2014-07-30 06:04:39 +04:00
|
|
|
|
2015-10-15 23:09:30 +03:00
|
|
|
showImg, err := getImage(daemon.repositories, container.Config.Image, container.ImageID)
|
2015-08-26 11:16:53 +03:00
|
|
|
if err != nil {
|
2015-10-15 23:09:30 +03:00
|
|
|
return nil, err
|
2015-08-26 11:16:53 +03:00
|
|
|
}
|
2015-10-15 23:09:30 +03:00
|
|
|
newC.Image = showImg
|
2015-04-04 03:39:06 +03:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
if len(container.Args) > 0 {
|
|
|
|
args := []string{}
|
|
|
|
for _, arg := range container.Args {
|
|
|
|
if strings.Contains(arg, " ") {
|
|
|
|
args = append(args, fmt.Sprintf("'%s'", arg))
|
|
|
|
} else {
|
|
|
|
args = append(args, arg)
|
2015-04-04 03:39:06 +03:00
|
|
|
}
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
argsAsString := strings.Join(args, " ")
|
2015-04-04 03:39:06 +03:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
newC.Command = fmt.Sprintf("%s %s", container.Path, argsAsString)
|
|
|
|
} else {
|
|
|
|
newC.Command = container.Path
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
newC.Created = container.Created.Unix()
|
|
|
|
newC.Status = container.State.String()
|
|
|
|
newC.HostConfig.NetworkMode = string(container.hostConfig.NetworkMode)
|
2014-07-30 06:04:39 +04:00
|
|
|
|
2015-08-26 11:16:53 +03:00
|
|
|
newC.Ports = []types.Port{}
|
|
|
|
for port, bindings := range container.NetworkSettings.Ports {
|
|
|
|
p, err := nat.ParsePort(port.Port())
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if len(bindings) == 0 {
|
|
|
|
newC.Ports = append(newC.Ports, types.Port{
|
|
|
|
PrivatePort: p,
|
|
|
|
Type: port.Proto(),
|
|
|
|
})
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
for _, binding := range bindings {
|
|
|
|
h, err := nat.ParsePort(binding.HostPort)
|
|
|
|
if err != nil {
|
2015-04-07 22:34:30 +03:00
|
|
|
return nil, err
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
newC.Ports = append(newC.Ports, types.Port{
|
|
|
|
PrivatePort: p,
|
|
|
|
PublicPort: h,
|
|
|
|
Type: port.Proto(),
|
|
|
|
IP: binding.HostIP,
|
|
|
|
})
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
|
|
|
}
|
2015-08-26 11:16:53 +03:00
|
|
|
|
2015-09-29 20:51:40 +03:00
|
|
|
if ctx.Size {
|
2015-11-03 04:06:09 +03:00
|
|
|
sizeRw, sizeRootFs := daemon.getSize(container)
|
2015-08-26 11:16:53 +03:00
|
|
|
newC.SizeRw = sizeRw
|
|
|
|
newC.SizeRootFs = sizeRootFs
|
|
|
|
}
|
|
|
|
newC.Labels = container.Config.Labels
|
|
|
|
|
|
|
|
return newC, nil
|
2014-07-30 06:04:39 +04:00
|
|
|
}
|
2015-06-12 16:25:32 +03:00
|
|
|
|
2015-07-31 00:01:53 +03:00
|
|
|
// Volumes lists known volumes, using the filter to restrict the range
|
|
|
|
// of volumes returned.
|
2015-09-29 20:51:40 +03:00
|
|
|
func (daemon *Daemon) Volumes(filter string) ([]*types.Volume, error) {
|
2015-06-12 16:25:32 +03:00
|
|
|
var volumesOut []*types.Volume
|
|
|
|
volFilters, err := filters.FromParam(filter)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
filterUsed := false
|
|
|
|
if i, ok := volFilters["dangling"]; ok {
|
|
|
|
if len(i) > 1 {
|
2015-09-18 20:48:16 +03:00
|
|
|
return nil, derr.ErrorCodeDanglingOne
|
2015-06-12 16:25:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
filterValue := i[0]
|
|
|
|
if strings.ToLower(filterValue) == "true" || filterValue == "1" {
|
|
|
|
filterUsed = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
volumes := daemon.volumes.List()
|
|
|
|
for _, v := range volumes {
|
2015-09-06 01:44:29 +03:00
|
|
|
if filterUsed && daemon.volumes.Count(v) > 0 {
|
2015-06-12 16:25:32 +03:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
volumesOut = append(volumesOut, volumeToAPIType(v))
|
|
|
|
}
|
|
|
|
return volumesOut, nil
|
|
|
|
}
|
2015-08-20 10:57:15 +03:00
|
|
|
|
|
|
|
func populateImageFilterByParents(ancestorMap map[string]bool, imageID string, byParents map[string][]*image.Image) {
|
|
|
|
if !ancestorMap[imageID] {
|
|
|
|
if images, ok := byParents[imageID]; ok {
|
|
|
|
for _, image := range images {
|
|
|
|
populateImageFilterByParents(ancestorMap, image.ID, byParents)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ancestorMap[imageID] = true
|
|
|
|
}
|
|
|
|
}
|