Exemple #1
0
// Safely remove the given container. It will deal with the error by logging
// it.
func removeContainer(id string) {
	client := getDockerClient()

	err := client.ContainerRemove(types.ContainerRemoveOptions{
		ContainerID:   id,
		RemoveVolumes: true,
		Force:         true,
	})
	if err != nil {
		log.Println(err)
	}
}
func (s *CliSuite) TearDownTest(c *C) {
	// Delete all containers
	client := GetClient(c)

	containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{
		All: true,
	})
	c.Assert(err, IsNil)
	for _, container := range containers {
		// Unpause container (if paused) and ignore error (if wasn't paused)
		client.ContainerUnpause(context.Background(), container.ID)
		// And remove force \o/
		err := client.ContainerRemove(context.Background(), container.ID, types.ContainerRemoveOptions{
			Force:         true,
			RemoveVolumes: true,
		})
		c.Assert(err, IsNil)
	}
}