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


Golang Client.StopContainer方法代码示例

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


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

示例1: main

func main() {

	fmt.Println("dockerapi started...")
	time.Sleep(time.Millisecond * 5000)
	fmt.Println("action: " + ACTION)
	fmt.Println("containers: " + CONTAINERS)
	var containers = strings.Split(CONTAINERS, ",")
	var docker *dockerapi.Client
	var err error
	docker, err = dockerapi.NewClient(DOCKER_HOST)
	if err != nil {
		fmt.Println(err.Error())
	}
	err = docker.Ping()

	for i := range containers {
		fmt.Println(ACTION + " issued for " + containers[i])
		switch ACTION {
		case "stop":
			err = docker.StopContainer(containers[i], 5)
		case "start":
			err = docker.StartContainer(containers[i], nil)
		default:
			fmt.Println(ACTION + " unsupported action")
		}
		if err != nil {
			fmt.Println(err.Error())
		}
		time.Sleep(time.Millisecond * 2000)
	}
}
开发者ID:CrunchyData,项目名称:crunchy-postgresql-manager-openshift,代码行数:31,代码来源:dockerapi.go

示例2: cleanUp

// cleanUp stops and removes the deployed router
func cleanUp(dockerCli *dockerClient.Client, routerId string) {
	dockerCli.StopContainer(routerId, 5)

	dockerCli.RemoveContainer(dockerClient.RemoveContainerOptions{
		ID:    routerId,
		Force: true,
	})
}
开发者ID:jhadvig,项目名称:origin,代码行数:9,代码来源:router_test.go

示例3: cleanUp

// cleanUp stops and removes the deployed router
func cleanUp(t *testing.T, dockerCli *dockerClient.Client, routerId string) {
	dockerCli.StopContainer(routerId, 5)
	if t.Failed() {
		dockerCli.Logs(dockerClient.LogsOptions{
			Container:    routerId,
			OutputStream: os.Stdout,
			ErrorStream:  os.Stderr,
			Stdout:       true,
			Stderr:       true,
		})
	}

	dockerCli.RemoveContainer(dockerClient.RemoveContainerOptions{
		ID:    routerId,
		Force: true,
	})
}
开发者ID:ncdc,项目名称:origin,代码行数:18,代码来源:router_test.go

示例4: renameOld

func (c *Container) renameOld(client *dockerClient.Client, opts *dockerClient.CreateContainerOptions) error {
	if len(opts.Name) == 0 {
		return nil
	}

	existing, err := inspect(client, opts.Name)
	if _, ok := err.(*dockerClient.NoSuchContainer); ok {
		return nil
	}

	if err != nil {
		return nil
	}

	if c.Container != nil && existing.ID == c.Container.ID {
		return nil
	}

	var newName string
	if label, ok := existing.Config.Labels[config.HASH]; ok {
		newName = fmt.Sprintf("%s-%s", existing.Name, label)
	} else {
		newName = fmt.Sprintf("%s-unknown-%s", existing.Name, util.RandSeq(12))
	}

	if existing.State.Running {
		err := client.StopContainer(existing.ID, 2)
		if err != nil {
			return err
		}

		_, err = client.WaitContainer(existing.ID)
		if err != nil {
			return err
		}
	}

	log.Debugf("Renaming %s to %s", existing.Name, newName)
	return client.RenameContainer(dockerClient.RenameContainerOptions{ID: existing.ID, Name: newName})
}
开发者ID:Hellslicer,项目名称:os,代码行数:40,代码来源:container.go

示例5: StopContainers

// StopContainers stops all the containers in ids slice
func StopContainers(client *docker.Client, ids []string) {
	for _, id := range ids {
		client.StopContainer(id, 10)
	}
}
开发者ID:jojimt,项目名称:contrib,代码行数:6,代码来源:docker_helpers.go


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