mirror of https://github.com/docker/docs.git
'docker kill': kill a running container without losing its filesystem and log state
This commit is contained in:
parent
5926cfd0ec
commit
bded592a15
|
@ -35,6 +35,7 @@ func (srv *Server) Help() string {
|
||||||
{"pull", "Download a tarball and create a container from it"},
|
{"pull", "Download a tarball and create a container from it"},
|
||||||
{"put", "Upload a tarball and create a container from it"},
|
{"put", "Upload a tarball and create a container from it"},
|
||||||
{"rm", "Remove containers"},
|
{"rm", "Remove containers"},
|
||||||
|
{"kill", "Kill a running container"},
|
||||||
{"wait", "Wait for the state of a container to change"},
|
{"wait", "Wait for the state of a container to change"},
|
||||||
{"stop", "Stop a running container"},
|
{"stop", "Stop a running container"},
|
||||||
{"logs", "Fetch the logs of a container"},
|
{"logs", "Fetch the logs of a container"},
|
||||||
|
@ -271,6 +272,24 @@ func (srv *Server) CmdRm(stdin io.ReadCloser, stdout io.Writer, args ...string)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'docker kill NAME' kills a running container
|
||||||
|
func (srv *Server) CmdKill(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
|
cmd := rcli.Subcmd(stdout, "kill", "[OPTIONS] CONTAINER [CONTAINER...]", "Kill a running container")
|
||||||
|
if err := cmd.Parse(args); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, name := range cmd.Args() {
|
||||||
|
container := srv.containers.Get(name)
|
||||||
|
if container == nil {
|
||||||
|
return errors.New("No such container: " + name)
|
||||||
|
}
|
||||||
|
if err := container.Kill(); err != nil {
|
||||||
|
fmt.Fprintln(stdout, "Error killing container " + name + ": " + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return errors.New("Not enough arguments")
|
return errors.New("Not enough arguments")
|
||||||
|
|
Loading…
Reference in New Issue