|
@@ -1,15 +1,15 @@
|
|
|
package server
|
|
|
|
|
|
import (
|
|
|
- ".."
|
|
|
- "../fs"
|
|
|
- "../future"
|
|
|
- "../rcli"
|
|
|
"bufio"
|
|
|
"bytes"
|
|
|
"encoding/json"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
+ "github.com/dotcloud/docker"
|
|
|
+ "github.com/dotcloud/docker/fs"
|
|
|
+ "github.com/dotcloud/docker/future"
|
|
|
+ "github.com/dotcloud/docker/rcli"
|
|
|
"io"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
@@ -60,8 +60,6 @@ func (srv *Server) Help() string {
|
|
|
{"mirror", "(debug only) (No documentation available)"},
|
|
|
{"port", "Lookup the public-facing port which is NAT-ed to PRIVATE_PORT"},
|
|
|
{"ps", "List containers"},
|
|
|
- {"pull", "Download a new image from a remote location"},
|
|
|
- {"put", "Import a new image from a local archive"},
|
|
|
{"reset", "Reset changes to a container's filesystem"},
|
|
|
{"restart", "Restart a running container"},
|
|
|
{"rm", "Remove a container"},
|
|
@@ -71,6 +69,7 @@ func (srv *Server) Help() string {
|
|
|
{"stop", "Stop a running container"},
|
|
|
{"tar", "Stream the contents of a container as a tar archive"},
|
|
|
{"umount", "(debug only) Mount a container's filesystem"},
|
|
|
+ {"version", "Show the docker version information"},
|
|
|
{"wait", "Block until a container stops, then print its exit code"},
|
|
|
{"web", "A web UI for docker"},
|
|
|
{"write", "Write the contents of standard input to a container's file"},
|
|
@@ -100,20 +99,33 @@ func (srv *Server) CmdWait(stdin io.ReadCloser, stdout io.Writer, args ...string
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+// 'docker version': show version information
|
|
|
+func (srv *Server) CmdVersion(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
|
|
+ fmt.Fprintf(stdout, "Version:%s\n", VERSION)
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
// 'docker info': display system-wide information.
|
|
|
func (srv *Server) CmdInfo(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
|
|
+ images, _ := srv.images.Images()
|
|
|
+ var imgcount int
|
|
|
+ if images == nil {
|
|
|
+ imgcount = 0
|
|
|
+ } else {
|
|
|
+ imgcount = len(images)
|
|
|
+ }
|
|
|
cmd := rcli.Subcmd(stdout, "info", "", "Display system-wide information.")
|
|
|
if err := cmd.Parse(args); err != nil {
|
|
|
return nil
|
|
|
}
|
|
|
- if cmd.NArg() > 1 {
|
|
|
+ if cmd.NArg() > 0 {
|
|
|
cmd.Usage()
|
|
|
return nil
|
|
|
}
|
|
|
fmt.Fprintf(stdout, "containers: %d\nversion: %s\nimages: %d\n",
|
|
|
len(srv.containers.List()),
|
|
|
VERSION,
|
|
|
- len(srv.images.ById))
|
|
|
+ imgcount)
|
|
|
return nil
|
|
|
}
|
|
|
|
|
@@ -732,10 +744,17 @@ func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string
|
|
|
return errors.New("No such container: " + cmd.Arg(0))
|
|
|
}
|
|
|
|
|
|
-func (srv *Server) CreateContainer(img *fs.Image, ports []int, user string, tty bool, openStdin bool, comment string, cmd string, args ...string) (*docker.Container, error) {
|
|
|
+func (srv *Server) CreateContainer(img *fs.Image, ports []int, user string, tty bool, openStdin bool, memory int64, comment string, cmd string, args ...string) (*docker.Container, error) {
|
|
|
id := future.RandomId()[:8]
|
|
|
container, err := srv.containers.Create(id, cmd, args, img,
|
|
|
- &docker.Config{Hostname: id, Ports: ports, User: user, Tty: tty, OpenStdin: openStdin})
|
|
|
+ &docker.Config{
|
|
|
+ Hostname: id,
|
|
|
+ Ports: ports,
|
|
|
+ User: user,
|
|
|
+ Tty: tty,
|
|
|
+ OpenStdin: openStdin,
|
|
|
+ Memory: memory,
|
|
|
+ })
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|