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


Golang DockerClient.RemoveContainer方法代码示例

本文整理汇总了Golang中github.com/samalba/dockerclient.DockerClient.RemoveContainer方法的典型用法代码示例。如果您正苦于以下问题:Golang DockerClient.RemoveContainer方法的具体用法?Golang DockerClient.RemoveContainer怎么用?Golang DockerClient.RemoveContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/samalba/dockerclient.DockerClient的用法示例。


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

示例1: stopAndDeleteDevice

func stopAndDeleteDevice(deviceSn string, docker *dc.DockerClient) error {
	container := "device" + deviceSn
	err := docker.KillContainer(container)
	if err != nil {
		return err
	}

	err = docker.RemoveContainer(container)
	return nil
}
开发者ID:jvermillard,项目名称:daas,代码行数:10,代码来源:main.go

示例2: removeContainers

func removeContainers(client *dockerclient.DockerClient, containers []*dockerclient.ContainerInfo) error {
	for _, container := range containers {
		log.Printf("rm %s (%s)", container.Id, container.Name)
		if !*dry {
			if err := client.RemoveContainer(container.Id, false, false); err != nil {
				debug("Couldn't remove container: %s", err)
			}
		}
	}
	return nil
}
开发者ID:dawidmalina,项目名称:docker-proper,代码行数:11,代码来源:docker-proper.go

示例3: Exec

func (job *Job) Exec(docker *dockerclient.DockerClient,
	w io.Writer) error {

	containerConfig := &dockerclient.ContainerConfig{
		Image:        job.Image,
		Cmd:          []string{"/bin/bash", "-c", job.Cmd},
		AttachStdout: true,
		AttachStderr: true,
	}
	cid, err := docker.CreateContainer(containerConfig,
		fmt.Sprintf("spot-trader-job-%d", job.ID))
	if err != nil {
		return fmt.Errorf("creating container: %v", err)
	}
	defer func() {
		if err = docker.RemoveContainer(cid, false, false); err != nil {
			log.Printf("error removing container: %v", err)
		}
	}()
	options := &dockerclient.AttachOptions{Stdout: true, Stderr: true, Stream: true}
	stdout, err := docker.AttachContainer(cid, options)
	if err != nil {
		return fmt.Errorf("attaching: %v", err)
	}
	err = docker.StartContainer(cid, nil)
	if err != nil {
		return fmt.Errorf("starting container: %v", err)
	}
	done := make(chan struct{})
	go func() {
		err := copyDockerOut(w, w, stdout)
		if err != nil {
			log.Println(err)
		}
		stdout.Close()
		close(done)
	}()
	<-done
	err = docker.StopContainer(cid, 5)
	if err != nil {
		log.Printf("error stopping container: %v",
			err)
	}
	return nil
}
开发者ID:bajh,项目名称:spot-trader,代码行数:45,代码来源:worker.go

示例4: supprDocker

func supprDocker(docker *dockerclient.DockerClient, dockerName string) {

	var searchDockerName string = "{\"name\":[\"" + dockerName + "\"]}"
	//l4g.Info("%v\n", searchDockerName)
	// Get only running containers
	containers, err := docker.ListContainers(true, true, searchDockerName)
	if err != nil {
		log.Fatal(err)
	}
	for _, c := range containers {
		l4g.Info(c.Id, c.Names)

		if err := docker.RemoveContainer(c.Id, true, false); err != nil {
			//l4g.Info("cannot stop container: %s", err)
			var RS string = fmt.Sprintf("cannot stop container: %s", err)
			l4g.Info(RS)
			writeSDLstr(RS)

		}
	}
}
开发者ID:AlexandreBRUXELLE,项目名称:goStartDockerViaRabbitMQ,代码行数:21,代码来源:main.go

示例5: stopVaultOnShutdown

func stopVaultOnShutdown(containerId string, docker *dockerclient.DockerClient) {
	log.Info("... stopping container ", containerId, "...")
	docker.StopContainer(containerId, 5)
	docker.RemoveContainer(containerId, true, false)
}
开发者ID:xtraclabs,项目名称:roll,代码行数:5,代码来源:runvaultmachine.go


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