summaryrefslogtreecommitdiff
path: root/vendor/github.com/fsouza/go-dockerclient/container_restart.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-10-26 11:35:02 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-10-29 15:06:22 +0100
commit65a618886efc48562e5b9ff99ca630c83622419b (patch)
tree09d19a7f6fe596a1b9e19fec6e45288f2b76de5a /vendor/github.com/fsouza/go-dockerclient/container_restart.go
parentcce6c6cd40137c460f173300b36c5868383870c5 (diff)
downloadpodman-65a618886efc48562e5b9ff99ca630c83622419b.tar.gz
podman-65a618886efc48562e5b9ff99ca630c83622419b.tar.bz2
podman-65a618886efc48562e5b9ff99ca630c83622419b.zip
new "image" mount type
Add a new "image" mount type to `--mount`. The source of the mount is the name or ID of an image. The destination is the path inside the container. Image mounts further support an optional `rw,readwrite` parameter which if set to "true" will yield the mount writable inside the container. Note that no changes are propagated to the image mount on the host (which in any case is read only). Mounts are overlay mounts. To support read-only overlay mounts, vendor a non-release version of Buildah. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/container_restart.go')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/container_restart.go62
1 files changed, 62 insertions, 0 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/container_restart.go b/vendor/github.com/fsouza/go-dockerclient/container_restart.go
new file mode 100644
index 000000000..90e59055c
--- /dev/null
+++ b/vendor/github.com/fsouza/go-dockerclient/container_restart.go
@@ -0,0 +1,62 @@
+package docker
+
+import (
+ "fmt"
+ "net/http"
+)
+
+// RestartPolicy represents the policy for automatically restarting a container.
+//
+// Possible values are:
+//
+// - always: the docker daemon will always restart the container
+// - on-failure: the docker daemon will restart the container on failures, at
+// most MaximumRetryCount times
+// - unless-stopped: the docker daemon will always restart the container except
+// when user has manually stopped the container
+// - no: the docker daemon will not restart the container automatically
+type RestartPolicy struct {
+ Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
+ MaximumRetryCount int `json:"MaximumRetryCount,omitempty" yaml:"MaximumRetryCount,omitempty" toml:"MaximumRetryCount,omitempty"`
+}
+
+// AlwaysRestart returns a restart policy that tells the Docker daemon to
+// always restart the container.
+func AlwaysRestart() RestartPolicy {
+ return RestartPolicy{Name: "always"}
+}
+
+// RestartOnFailure returns a restart policy that tells the Docker daemon to
+// restart the container on failures, trying at most maxRetry times.
+func RestartOnFailure(maxRetry int) RestartPolicy {
+ return RestartPolicy{Name: "on-failure", MaximumRetryCount: maxRetry}
+}
+
+// RestartUnlessStopped returns a restart policy that tells the Docker daemon to
+// always restart the container except when user has manually stopped the container.
+func RestartUnlessStopped() RestartPolicy {
+ return RestartPolicy{Name: "unless-stopped"}
+}
+
+// NeverRestart returns a restart policy that tells the Docker daemon to never
+// restart the container on failures.
+func NeverRestart() RestartPolicy {
+ return RestartPolicy{Name: "no"}
+}
+
+// RestartContainer stops a container, killing it after the given timeout (in
+// seconds), during the stop process.
+//
+// See https://goo.gl/MrAKQ5 for more details.
+func (c *Client) RestartContainer(id string, timeout uint) error {
+ path := fmt.Sprintf("/containers/%s/restart?t=%d", id, timeout)
+ resp, err := c.do(http.MethodPost, path, doOptions{})
+ if err != nil {
+ if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
+ return &NoSuchContainer{ID: id}
+ }
+ return err
+ }
+ resp.Body.Close()
+ return nil
+}