当前位置: 首页>>代码示例>>Golang>>正文


Golang client.IsErrContainerNotFound函数代码示例

本文整理汇总了Golang中github.com/docker/engine-api/client.IsErrContainerNotFound函数的典型用法代码示例。如果您正苦于以下问题:Golang IsErrContainerNotFound函数的具体用法?Golang IsErrContainerNotFound怎么用?Golang IsErrContainerNotFound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IsErrContainerNotFound函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: inspectAll

func (cli *DockerCli) inspectAll(ctx context.Context, getSize bool) inspect.GetRefFunc {
	return func(ref string) (interface{}, []byte, error) {
		c, rawContainer, err := cli.client.ContainerInspectWithRaw(ctx, ref, getSize)
		if err != nil {
			// Search for image with that id if a container doesn't exist.
			if client.IsErrContainerNotFound(err) {
				i, rawImage, err := cli.client.ImageInspectWithRaw(ctx, ref, getSize)
				if err != nil {
					if client.IsErrImageNotFound(err) {
						// Search for task with that id if an image doesn't exists.
						t, rawTask, err := cli.client.TaskInspectWithRaw(ctx, ref)
						if err != nil {
							return nil, nil, fmt.Errorf("Error: No such image, container or task: %s", ref)
						}
						if getSize {
							fmt.Fprintln(cli.err, "WARNING: --size ignored for tasks")
						}
						return t, rawTask, nil
					}
					return nil, nil, err
				}
				return i, rawImage, err
			}
			return nil, nil, err
		}
		return c, rawContainer, err
	}
}
开发者ID:FlyingShit-XinHuang,项目名称:docker,代码行数:28,代码来源:inspect.go

示例2: InspectContainer

func (d *kubeDockerClient) InspectContainer(id string) (*dockertypes.ContainerJSON, error) {
	containerJSON, err := d.client.ContainerInspect(getDefaultContext(), id)
	if err != nil {
		if dockerapi.IsErrContainerNotFound(err) {
			return nil, containerNotFoundError{ID: id}
		}
		return nil, err
	}
	return &containerJSON, nil
}
开发者ID:mattjmcnaughton,项目名称:kubernetes,代码行数:10,代码来源:kube_docker_client.go

示例3: GetContainer

// GetContainer looks up the hosts containers with the specified ID
// or name and returns it, or an error.
func GetContainer(ctx context.Context, clientInstance client.APIClient, id string) (*types.ContainerJSON, error) {
	container, err := clientInstance.ContainerInspect(ctx, id)
	if err != nil {
		if client.IsErrContainerNotFound(err) {
			return nil, nil
		}
		return nil, err
	}
	return &container, nil
}
开发者ID:haj,项目名称:kompose,代码行数:12,代码来源:functions.go

示例4: InspectContainer

func (d *kubeDockerClient) InspectContainer(id string) (*dockertypes.ContainerJSON, error) {
	ctx, cancel := d.getTimeoutContext()
	defer cancel()
	containerJSON, err := d.client.ContainerInspect(ctx, id)
	if ctxErr := contextError(ctx); ctxErr != nil {
		return nil, ctxErr
	}
	if err != nil {
		if dockerapi.IsErrContainerNotFound(err) {
			return nil, containerNotFoundError{ID: id}
		}
		return nil, err
	}
	return &containerJSON, nil
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:15,代码来源:kube_docker_client.go

示例5: InspectContainer

func (d *kubeDockerClient) InspectContainer(id string) (*docker.Container, error) {
	containerJSON, err := d.client.ContainerInspect(getDefaultContext(), id)
	if err != nil {
		// TODO(random-liu): Use IsErrContainerNotFound instead of NoSuchContainer error
		if dockerapi.IsErrContainerNotFound(err) {
			err = &docker.NoSuchContainer{ID: id, Err: err}
		}
		return nil, err
	}
	container := &docker.Container{}
	if err := convertType(&containerJSON, container); err != nil {
		return nil, err
	}
	return container, nil
}
开发者ID:RomainVabre,项目名称:origin,代码行数:15,代码来源:kube_docker_client.go

示例6: inspectAll

func (cli *DockerCli) inspectAll(getSize bool) inspectSearcher {
	return func(ref string) (interface{}, []byte, error) {
		c, rawContainer, err := cli.client.ContainerInspectWithRaw(ref, getSize)
		if err != nil {
			// Search for image with that id if a container doesn't exist.
			if client.IsErrContainerNotFound(err) {
				i, rawImage, err := cli.client.ImageInspectWithRaw(ref, getSize)
				if err != nil {
					if client.IsErrImageNotFound(err) {
						return nil, nil, fmt.Errorf("Error: No such image or container: %s", ref)
					}
					return nil, nil, err
				}
				return i, rawImage, err
			}
			return nil, nil, err
		}
		return c, rawContainer, err
	}
}
开发者ID:dfilion,项目名称:docker,代码行数:20,代码来源:inspect.go

示例7: cleanUpDockerDandlingEndpoints

// cleanUpDockerDandlingEndpoints cleans all endpoints that are dandling by checking out
// if a particular endpoint has its container running.
func (d *Daemon) cleanUpDockerDandlingEndpoints() {
	eps, _ := d.EndpointsGet()
	if eps == nil {
		return
	}

	cleanUp := func(ep endpoint.Endpoint) {
		log.Infof("Endpoint %d not found in docker, cleaning up...", ep.ID)
		d.EndpointLeave(ep.ID)
		// FIXME: IPV4
		if ep.IPv6 != nil {
			if ep.IsCNI() {
				d.ReleaseIP(ipam.CNIIPAMType, ep.IPv6.IPAMReq())
			} else if ep.IsLibnetwork() {
				d.ReleaseIP(ipam.LibnetworkIPAMType, ep.IPv6.IPAMReq())
			}
		}

	}

	for _, ep := range eps {
		log.Debugf("Checking if endpoint is running in docker %d", ep.ID)
		if ep.DockerNetworkID != "" {
			nls, err := d.dockerClient.NetworkInspect(ctx.Background(), ep.DockerNetworkID)
			if dockerAPI.IsErrNetworkNotFound(err) {
				cleanUp(ep)
				continue
			}
			if err != nil {
				continue
			}
			found := false
			for _, v := range nls.Containers {
				if v.EndpointID == ep.DockerEndpointID {
					found = true
					break
				}
			}
			if !found {
				cleanUp(ep)
				continue
			}
		} else if ep.DockerID != "" {
			cont, err := d.dockerClient.ContainerInspect(ctx.Background(), ep.DockerID)
			if dockerAPI.IsErrContainerNotFound(err) {
				cleanUp(ep)
				continue
			}
			if err != nil {
				continue
			}
			if !cont.State.Running {
				cleanUp(ep)
				continue
			}
		} else {
			cleanUp(ep)
			continue
		}
	}
}
开发者ID:cilium-team,项目名称:cilium,代码行数:63,代码来源:state.go


注:本文中的github.com/docker/engine-api/client.IsErrContainerNotFound函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。