| ... | ... |
@@ -48,6 +48,8 @@ func (srv *Server) Help() string {
|
| 48 | 48 |
{"kill", "Kill a running container"},
|
| 49 | 49 |
{"wait", "Wait for the state of a container to change"},
|
| 50 | 50 |
{"stop", "Stop a running container"},
|
| 51 |
+ {"start", "Start a stopped container"},
|
|
| 52 |
+ {"restart", "Restart a running container"},
|
|
| 51 | 53 |
{"logs", "Fetch the logs of a container"},
|
| 52 | 54 |
{"diff", "Inspect changes on a container's filesystem"},
|
| 53 | 55 |
{"commit", "Save the state of a container"},
|
| ... | ... |
@@ -94,6 +96,52 @@ func (srv *Server) CmdStop(stdin io.ReadCloser, stdout io.Writer, args ...string |
| 94 | 94 |
return nil |
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 |
+func (srv *Server) CmdRestart(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
|
| 98 |
+ cmd := rcli.Subcmd(stdout, "restart", "[OPTIONS] NAME", "Restart a running container") |
|
| 99 |
+ if err := cmd.Parse(args); err != nil {
|
|
| 100 |
+ cmd.Usage() |
|
| 101 |
+ return nil |
|
| 102 |
+ } |
|
| 103 |
+ if cmd.NArg() < 1 {
|
|
| 104 |
+ cmd.Usage() |
|
| 105 |
+ return nil |
|
| 106 |
+ } |
|
| 107 |
+ for _, name := range cmd.Args() {
|
|
| 108 |
+ if container := srv.containers.Get(name); container != nil {
|
|
| 109 |
+ if err := container.Restart(); err != nil {
|
|
| 110 |
+ return err |
|
| 111 |
+ } |
|
| 112 |
+ fmt.Fprintln(stdout, container.Id) |
|
| 113 |
+ } else {
|
|
| 114 |
+ return errors.New("No such container: " + name)
|
|
| 115 |
+ } |
|
| 116 |
+ } |
|
| 117 |
+ return nil |
|
| 118 |
+} |
|
| 119 |
+ |
|
| 120 |
+func (srv *Server) CmdStart(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
|
| 121 |
+ cmd := rcli.Subcmd(stdout, "start", "[OPTIONS] NAME", "Start a stopped container") |
|
| 122 |
+ if err := cmd.Parse(args); err != nil {
|
|
| 123 |
+ cmd.Usage() |
|
| 124 |
+ return nil |
|
| 125 |
+ } |
|
| 126 |
+ if cmd.NArg() < 1 {
|
|
| 127 |
+ cmd.Usage() |
|
| 128 |
+ return nil |
|
| 129 |
+ } |
|
| 130 |
+ for _, name := range cmd.Args() {
|
|
| 131 |
+ if container := srv.containers.Get(name); container != nil {
|
|
| 132 |
+ if err := container.Start(); err != nil {
|
|
| 133 |
+ return err |
|
| 134 |
+ } |
|
| 135 |
+ fmt.Fprintln(stdout, container.Id) |
|
| 136 |
+ } else {
|
|
| 137 |
+ return errors.New("No such container: " + name)
|
|
| 138 |
+ } |
|
| 139 |
+ } |
|
| 140 |
+ return nil |
|
| 141 |
+} |
|
| 142 |
+ |
|
| 97 | 143 |
func (srv *Server) CmdUmount(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
| 98 | 144 |
cmd := rcli.Subcmd(stdout, "umount", "[OPTIONS] NAME", "umount a container's filesystem (debug only)") |
| 99 | 145 |
if err := cmd.Parse(args); err != nil {
|