From 55333e8f9018585f28f13231a3073e2746d7c969 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 4 Dec 2015 11:38:36 -0500 Subject: [PATCH] Implement docker pause with standalone client lib. Signed-off-by: David Calavera --- api/client/lib/pause.go | 8 ++++++++ api/client/pause.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 api/client/lib/pause.go diff --git a/api/client/lib/pause.go b/api/client/lib/pause.go new file mode 100644 index 0000000000..3247ec3a57 --- /dev/null +++ b/api/client/lib/pause.go @@ -0,0 +1,8 @@ +package lib + +// ContainerPause pauses the main process of a given container without terminating it. +func (cli *Client) ContainerPause(containerID string) error { + resp, err := cli.post("/containers/"+containerID+"/pause", nil, nil, nil) + ensureReaderClosed(resp) + return err +} diff --git a/api/client/pause.go b/api/client/pause.go index e144a0bd55..76de3e3d59 100644 --- a/api/client/pause.go +++ b/api/client/pause.go @@ -18,7 +18,7 @@ func (cli *DockerCli) CmdPause(args ...string) error { var errNames []string for _, name := range cmd.Args() { - if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/pause", name), nil, nil)); err != nil { + if err := cli.client.ContainerPause(name); err != nil { fmt.Fprintf(cli.err, "%s\n", err) errNames = append(errNames, name) } else {