'docker kill': kill a running container without losing its filesystem and log state
Upstream-commit: bded592a15403e92feb06dcbbed41eb385cabb84 Component: engine
This commit is contained in:
@ -35,6 +35,7 @@ func (srv *Server) Help() string {
|
||||
{"pull", "Download a tarball and create a container from it"},
|
||||
{"put", "Upload a tarball and create a container from it"},
|
||||
{"rm", "Remove containers"},
|
||||
{"kill", "Kill a running container"},
|
||||
{"wait", "Wait for the state of a container to change"},
|
||||
{"stop", "Stop a running 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
|
||||
}
|
||||
|
||||
// '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 {
|
||||
if len(args) < 1 {
|
||||
return errors.New("Not enough arguments")
|
||||
|
||||
Reference in New Issue
Block a user