podman

Форк
0
41 строка · 1.0 Кб
1
package docker
2

3
import (
4
	"context"
5
	"errors"
6
	"net/http"
7
)
8

9
// RemoveContainerOptions encapsulates options to remove a container.
10
//
11
// See https://goo.gl/hL5IPC for more details.
12
type RemoveContainerOptions struct {
13
	// The ID of the container.
14
	ID string `qs:"-"`
15

16
	// A flag that indicates whether Docker should remove the volumes
17
	// associated to the container.
18
	RemoveVolumes bool `qs:"v"`
19

20
	// A flag that indicates whether Docker should remove the container
21
	// even if it is currently running.
22
	Force   bool
23
	Context context.Context
24
}
25

26
// RemoveContainer removes a container, returning an error in case of failure.
27
//
28
// See https://goo.gl/hL5IPC for more details.
29
func (c *Client) RemoveContainer(opts RemoveContainerOptions) error {
30
	path := "/containers/" + opts.ID + "?" + queryString(opts)
31
	resp, err := c.do(http.MethodDelete, path, doOptions{context: opts.Context})
32
	if err != nil {
33
		var e *Error
34
		if errors.As(err, &e) && e.Status == http.StatusNotFound {
35
			return &NoSuchContainer{ID: opts.ID}
36
		}
37
		return err
38
	}
39
	resp.Body.Close()
40
	return nil
41
}
42

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.