| ... | ... |
@@ -890,24 +890,6 @@ func CmdAttach(args ...string) error {
|
| 890 | 890 |
return nil |
| 891 | 891 |
} |
| 892 | 892 |
|
| 893 |
-/* |
|
| 894 |
-// Ports type - Used to parse multiple -p flags |
|
| 895 |
-type ports []int |
|
| 896 |
- |
|
| 897 |
-func (p *ports) String() string {
|
|
| 898 |
- return fmt.Sprint(*p) |
|
| 899 |
-} |
|
| 900 |
- |
|
| 901 |
-func (p *ports) Set(value string) error {
|
|
| 902 |
- port, err := strconv.Atoi(value) |
|
| 903 |
- if err != nil {
|
|
| 904 |
- return fmt.Errorf("Invalid port: %v", value)
|
|
| 905 |
- } |
|
| 906 |
- *p = append(*p, port) |
|
| 907 |
- return nil |
|
| 908 |
-} |
|
| 909 |
-*/ |
|
| 910 |
- |
|
| 911 | 893 |
// ListOpts type |
| 912 | 894 |
type ListOpts []string |
| 913 | 895 |
|
| ... | ... |
@@ -1053,11 +1035,6 @@ func CmdRun(args ...string) error {
|
| 1053 | 1053 |
v.Set("stderr", "1")
|
| 1054 | 1054 |
|
| 1055 | 1055 |
} |
| 1056 |
- /* |
|
| 1057 |
- attach := Go(func() error {
|
|
| 1058 |
- err := hijack("POST", "/containers/"+out.Id+"/attach?"+v.Encode(), config.Tty)
|
|
| 1059 |
- return err |
|
| 1060 |
- })*/ |
|
| 1061 | 1056 |
|
| 1062 | 1057 |
//start the container |
| 1063 | 1058 |
_, _, err = call("POST", "/containers/"+out.Id+"/start", nil)
|
| 1064 | 1059 |
deleted file mode 100644 |
| ... | ... |
@@ -1,169 +0,0 @@ |
| 1 |
-package rcli |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "bufio" |
|
| 5 |
- "bytes" |
|
| 6 |
- "encoding/json" |
|
| 7 |
- "fmt" |
|
| 8 |
- "io" |
|
| 9 |
- "io/ioutil" |
|
| 10 |
- "log" |
|
| 11 |
- "net" |
|
| 12 |
-) |
|
| 13 |
- |
|
| 14 |
-// Note: the globals are here to avoid import cycle |
|
| 15 |
-// FIXME: Handle debug levels mode? |
|
| 16 |
-var DEBUG_FLAG bool = false |
|
| 17 |
-var CLIENT_SOCKET io.Writer = nil |
|
| 18 |
- |
|
| 19 |
-type DockerTCPConn struct {
|
|
| 20 |
- conn *net.TCPConn |
|
| 21 |
- options *DockerConnOptions |
|
| 22 |
- optionsBuf *[]byte |
|
| 23 |
- handshaked bool |
|
| 24 |
- client bool |
|
| 25 |
-} |
|
| 26 |
- |
|
| 27 |
-func NewDockerTCPConn(conn *net.TCPConn, client bool) *DockerTCPConn {
|
|
| 28 |
- return &DockerTCPConn{
|
|
| 29 |
- conn: conn, |
|
| 30 |
- options: &DockerConnOptions{},
|
|
| 31 |
- client: client, |
|
| 32 |
- } |
|
| 33 |
-} |
|
| 34 |
- |
|
| 35 |
-func (c *DockerTCPConn) SetOptionRawTerminal() {
|
|
| 36 |
- c.options.RawTerminal = true |
|
| 37 |
-} |
|
| 38 |
- |
|
| 39 |
-func (c *DockerTCPConn) GetOptions() *DockerConnOptions {
|
|
| 40 |
- if c.client && !c.handshaked {
|
|
| 41 |
- // Attempt to parse options encoded as a JSON dict and store |
|
| 42 |
- // the reminder of what we read from the socket in a buffer. |
|
| 43 |
- // |
|
| 44 |
- // bufio (and its ReadBytes method) would have been nice here, |
|
| 45 |
- // but if json.Unmarshal() fails (which will happen if we speak |
|
| 46 |
- // to a version of docker that doesn't send any option), then |
|
| 47 |
- // we can't put the data back in it for the next Read(). |
|
| 48 |
- c.handshaked = true |
|
| 49 |
- buf := make([]byte, 4096) |
|
| 50 |
- if n, _ := c.conn.Read(buf); n > 0 {
|
|
| 51 |
- buf = buf[:n] |
|
| 52 |
- if nl := bytes.IndexByte(buf, '\n'); nl != -1 {
|
|
| 53 |
- if err := json.Unmarshal(buf[:nl], c.options); err == nil {
|
|
| 54 |
- buf = buf[nl+1:] |
|
| 55 |
- } |
|
| 56 |
- } |
|
| 57 |
- c.optionsBuf = &buf |
|
| 58 |
- } |
|
| 59 |
- } |
|
| 60 |
- |
|
| 61 |
- return c.options |
|
| 62 |
-} |
|
| 63 |
- |
|
| 64 |
-func (c *DockerTCPConn) Read(b []byte) (int, error) {
|
|
| 65 |
- if c.optionsBuf != nil {
|
|
| 66 |
- // Consume what we buffered in GetOptions() first: |
|
| 67 |
- optionsBuf := *c.optionsBuf |
|
| 68 |
- optionsBuflen := len(optionsBuf) |
|
| 69 |
- copied := copy(b, optionsBuf) |
|
| 70 |
- if copied < optionsBuflen {
|
|
| 71 |
- optionsBuf = optionsBuf[copied:] |
|
| 72 |
- c.optionsBuf = &optionsBuf |
|
| 73 |
- return copied, nil |
|
| 74 |
- } |
|
| 75 |
- c.optionsBuf = nil |
|
| 76 |
- return copied, nil |
|
| 77 |
- } |
|
| 78 |
- return c.conn.Read(b) |
|
| 79 |
-} |
|
| 80 |
- |
|
| 81 |
-func (c *DockerTCPConn) Write(b []byte) (int, error) {
|
|
| 82 |
- optionsLen := 0 |
|
| 83 |
- if !c.client && !c.handshaked {
|
|
| 84 |
- c.handshaked = true |
|
| 85 |
- options, _ := json.Marshal(c.options) |
|
| 86 |
- options = append(options, '\n') |
|
| 87 |
- if optionsLen, err := c.conn.Write(options); err != nil {
|
|
| 88 |
- return optionsLen, err |
|
| 89 |
- } |
|
| 90 |
- } |
|
| 91 |
- n, err := c.conn.Write(b) |
|
| 92 |
- return n + optionsLen, err |
|
| 93 |
-} |
|
| 94 |
- |
|
| 95 |
-func (c *DockerTCPConn) Flush() error {
|
|
| 96 |
- _, err := c.Write([]byte{})
|
|
| 97 |
- return err |
|
| 98 |
-} |
|
| 99 |
- |
|
| 100 |
-func (c *DockerTCPConn) Close() error { return c.conn.Close() }
|
|
| 101 |
- |
|
| 102 |
-func (c *DockerTCPConn) CloseWrite() error { return c.conn.CloseWrite() }
|
|
| 103 |
- |
|
| 104 |
-func (c *DockerTCPConn) CloseRead() error { return c.conn.CloseRead() }
|
|
| 105 |
- |
|
| 106 |
-// Connect to a remote endpoint using protocol `proto` and address `addr`, |
|
| 107 |
-// issue a single call, and return the result. |
|
| 108 |
-// `proto` may be "tcp", "unix", etc. See the `net` package for available protocols. |
|
| 109 |
-func Call(proto, addr string, args ...string) (DockerConn, error) {
|
|
| 110 |
- cmd, err := json.Marshal(args) |
|
| 111 |
- if err != nil {
|
|
| 112 |
- return nil, err |
|
| 113 |
- } |
|
| 114 |
- conn, err := dialDocker(proto, addr) |
|
| 115 |
- if err != nil {
|
|
| 116 |
- return nil, err |
|
| 117 |
- } |
|
| 118 |
- if _, err := fmt.Fprintln(conn, string(cmd)); err != nil {
|
|
| 119 |
- return nil, err |
|
| 120 |
- } |
|
| 121 |
- return conn, nil |
|
| 122 |
-} |
|
| 123 |
- |
|
| 124 |
-// Listen on `addr`, using protocol `proto`, for incoming rcli calls, |
|
| 125 |
-// and pass them to `service`. |
|
| 126 |
-func ListenAndServe(proto, addr string, service Service) error {
|
|
| 127 |
- listener, err := net.Listen(proto, addr) |
|
| 128 |
- if err != nil {
|
|
| 129 |
- return err |
|
| 130 |
- } |
|
| 131 |
- log.Printf("Listening for RCLI/%s on %s\n", proto, addr)
|
|
| 132 |
- defer listener.Close() |
|
| 133 |
- for {
|
|
| 134 |
- if conn, err := listener.Accept(); err != nil {
|
|
| 135 |
- return err |
|
| 136 |
- } else {
|
|
| 137 |
- conn, err := newDockerServerConn(conn) |
|
| 138 |
- if err != nil {
|
|
| 139 |
- return err |
|
| 140 |
- } |
|
| 141 |
- go func(conn DockerConn) {
|
|
| 142 |
- defer conn.Close() |
|
| 143 |
- if DEBUG_FLAG {
|
|
| 144 |
- CLIENT_SOCKET = conn |
|
| 145 |
- } |
|
| 146 |
- if err := Serve(conn, service); err != nil {
|
|
| 147 |
- log.Println("Error:", err.Error())
|
|
| 148 |
- fmt.Fprintln(conn, "Error:", err.Error()) |
|
| 149 |
- } |
|
| 150 |
- }(conn) |
|
| 151 |
- } |
|
| 152 |
- } |
|
| 153 |
- return nil |
|
| 154 |
-} |
|
| 155 |
- |
|
| 156 |
-// Parse an rcli call on a new connection, and pass it to `service` if it |
|
| 157 |
-// is valid. |
|
| 158 |
-func Serve(conn DockerConn, service Service) error {
|
|
| 159 |
- r := bufio.NewReader(conn) |
|
| 160 |
- var args []string |
|
| 161 |
- if line, err := r.ReadString('\n'); err != nil {
|
|
| 162 |
- return err |
|
| 163 |
- } else if err := json.Unmarshal([]byte(line), &args); err != nil {
|
|
| 164 |
- return err |
|
| 165 |
- } else {
|
|
| 166 |
- return call(service, ioutil.NopCloser(r), conn, args...) |
|
| 167 |
- } |
|
| 168 |
- return nil |
|
| 169 |
-} |
| 170 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,181 +0,0 @@ |
| 1 |
-package rcli |
|
| 2 |
- |
|
| 3 |
-// rcli (Remote Command-Line Interface) is a simple protocol for... |
|
| 4 |
-// serving command-line interfaces remotely. |
|
| 5 |
-// |
|
| 6 |
-// rcli can be used over any transport capable of a) sending binary streams in |
|
| 7 |
-// both directions, and b) capable of half-closing a connection. TCP and Unix sockets |
|
| 8 |
-// are the usual suspects. |
|
| 9 |
- |
|
| 10 |
-import ( |
|
| 11 |
- "flag" |
|
| 12 |
- "fmt" |
|
| 13 |
- "github.com/dotcloud/docker/term" |
|
| 14 |
- "io" |
|
| 15 |
- "log" |
|
| 16 |
- "net" |
|
| 17 |
- "os" |
|
| 18 |
- "reflect" |
|
| 19 |
- "strings" |
|
| 20 |
-) |
|
| 21 |
- |
|
| 22 |
-type DockerConnOptions struct {
|
|
| 23 |
- RawTerminal bool |
|
| 24 |
-} |
|
| 25 |
- |
|
| 26 |
-type DockerConn interface {
|
|
| 27 |
- io.ReadWriteCloser |
|
| 28 |
- CloseWrite() error |
|
| 29 |
- CloseRead() error |
|
| 30 |
- GetOptions() *DockerConnOptions |
|
| 31 |
- SetOptionRawTerminal() |
|
| 32 |
- Flush() error |
|
| 33 |
-} |
|
| 34 |
- |
|
| 35 |
-type DockerLocalConn struct {
|
|
| 36 |
- writer io.WriteCloser |
|
| 37 |
- savedState *term.State |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-func NewDockerLocalConn(w io.WriteCloser) *DockerLocalConn {
|
|
| 41 |
- return &DockerLocalConn{
|
|
| 42 |
- writer: w, |
|
| 43 |
- } |
|
| 44 |
-} |
|
| 45 |
- |
|
| 46 |
-func (c *DockerLocalConn) Read(b []byte) (int, error) {
|
|
| 47 |
- return 0, fmt.Errorf("DockerLocalConn does not implement Read()")
|
|
| 48 |
-} |
|
| 49 |
- |
|
| 50 |
-func (c *DockerLocalConn) Write(b []byte) (int, error) { return c.writer.Write(b) }
|
|
| 51 |
- |
|
| 52 |
-func (c *DockerLocalConn) Close() error {
|
|
| 53 |
- if c.savedState != nil {
|
|
| 54 |
- RestoreTerminal(c.savedState) |
|
| 55 |
- c.savedState = nil |
|
| 56 |
- } |
|
| 57 |
- return c.writer.Close() |
|
| 58 |
-} |
|
| 59 |
- |
|
| 60 |
-func (c *DockerLocalConn) Flush() error { return nil }
|
|
| 61 |
- |
|
| 62 |
-func (c *DockerLocalConn) CloseWrite() error { return nil }
|
|
| 63 |
- |
|
| 64 |
-func (c *DockerLocalConn) CloseRead() error { return nil }
|
|
| 65 |
- |
|
| 66 |
-func (c *DockerLocalConn) GetOptions() *DockerConnOptions { return nil }
|
|
| 67 |
- |
|
| 68 |
-func (c *DockerLocalConn) SetOptionRawTerminal() {
|
|
| 69 |
- if state, err := SetRawTerminal(); err != nil {
|
|
| 70 |
- if os.Getenv("DEBUG") != "" {
|
|
| 71 |
- log.Printf("Can't set the terminal in raw mode: %s", err)
|
|
| 72 |
- } |
|
| 73 |
- } else {
|
|
| 74 |
- c.savedState = state |
|
| 75 |
- } |
|
| 76 |
-} |
|
| 77 |
- |
|
| 78 |
-var UnknownDockerProto = fmt.Errorf("Only TCP is actually supported by Docker at the moment")
|
|
| 79 |
- |
|
| 80 |
-func dialDocker(proto string, addr string) (DockerConn, error) {
|
|
| 81 |
- conn, err := net.Dial(proto, addr) |
|
| 82 |
- if err != nil {
|
|
| 83 |
- return nil, err |
|
| 84 |
- } |
|
| 85 |
- switch i := conn.(type) {
|
|
| 86 |
- case *net.TCPConn: |
|
| 87 |
- return NewDockerTCPConn(i, true), nil |
|
| 88 |
- } |
|
| 89 |
- return nil, UnknownDockerProto |
|
| 90 |
-} |
|
| 91 |
- |
|
| 92 |
-func newDockerFromConn(conn net.Conn, client bool) (DockerConn, error) {
|
|
| 93 |
- switch i := conn.(type) {
|
|
| 94 |
- case *net.TCPConn: |
|
| 95 |
- return NewDockerTCPConn(i, client), nil |
|
| 96 |
- } |
|
| 97 |
- return nil, UnknownDockerProto |
|
| 98 |
-} |
|
| 99 |
- |
|
| 100 |
-func newDockerServerConn(conn net.Conn) (DockerConn, error) {
|
|
| 101 |
- return newDockerFromConn(conn, false) |
|
| 102 |
-} |
|
| 103 |
- |
|
| 104 |
-type Service interface {
|
|
| 105 |
- Name() string |
|
| 106 |
- Help() string |
|
| 107 |
-} |
|
| 108 |
- |
|
| 109 |
-type Cmd func(io.ReadCloser, io.Writer, ...string) error |
|
| 110 |
-type CmdMethod func(Service, io.ReadCloser, io.Writer, ...string) error |
|
| 111 |
- |
|
| 112 |
-// FIXME: For reverse compatibility |
|
| 113 |
-func call(service Service, stdin io.ReadCloser, stdout DockerConn, args ...string) error {
|
|
| 114 |
- return LocalCall(service, stdin, stdout, args...) |
|
| 115 |
-} |
|
| 116 |
- |
|
| 117 |
-func LocalCall(service Service, stdin io.ReadCloser, stdout DockerConn, args ...string) error {
|
|
| 118 |
- if len(args) == 0 {
|
|
| 119 |
- args = []string{"help"}
|
|
| 120 |
- } |
|
| 121 |
- flags := flag.NewFlagSet("main", flag.ContinueOnError)
|
|
| 122 |
- flags.SetOutput(stdout) |
|
| 123 |
- flags.Usage = func() { stdout.Write([]byte(service.Help())) }
|
|
| 124 |
- if err := flags.Parse(args); err != nil {
|
|
| 125 |
- return err |
|
| 126 |
- } |
|
| 127 |
- cmd := flags.Arg(0) |
|
| 128 |
- log.Printf("%s\n", strings.Join(append(append([]string{service.Name()}, cmd), flags.Args()[1:]...), " "))
|
|
| 129 |
- if cmd == "" {
|
|
| 130 |
- cmd = "help" |
|
| 131 |
- } |
|
| 132 |
- method := getMethod(service, cmd) |
|
| 133 |
- if method != nil {
|
|
| 134 |
- return method(stdin, stdout, flags.Args()[1:]...) |
|
| 135 |
- } |
|
| 136 |
- return fmt.Errorf("No such command: %s", cmd)
|
|
| 137 |
-} |
|
| 138 |
- |
|
| 139 |
-func getMethod(service Service, name string) Cmd {
|
|
| 140 |
- if name == "help" {
|
|
| 141 |
- return func(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
|
| 142 |
- if len(args) == 0 {
|
|
| 143 |
- stdout.Write([]byte(service.Help())) |
|
| 144 |
- } else {
|
|
| 145 |
- if method := getMethod(service, args[0]); method == nil {
|
|
| 146 |
- return fmt.Errorf("No such command: %s", args[0])
|
|
| 147 |
- } else {
|
|
| 148 |
- method(stdin, stdout, "--help") |
|
| 149 |
- } |
|
| 150 |
- } |
|
| 151 |
- return nil |
|
| 152 |
- } |
|
| 153 |
- } |
|
| 154 |
- methodName := "Cmd" + strings.ToUpper(name[:1]) + strings.ToLower(name[1:]) |
|
| 155 |
- method, exists := reflect.TypeOf(service).MethodByName(methodName) |
|
| 156 |
- if !exists {
|
|
| 157 |
- return nil |
|
| 158 |
- } |
|
| 159 |
- return func(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
|
| 160 |
- ret := method.Func.CallSlice([]reflect.Value{
|
|
| 161 |
- reflect.ValueOf(service), |
|
| 162 |
- reflect.ValueOf(stdin), |
|
| 163 |
- reflect.ValueOf(stdout), |
|
| 164 |
- reflect.ValueOf(args), |
|
| 165 |
- })[0].Interface() |
|
| 166 |
- if ret == nil {
|
|
| 167 |
- return nil |
|
| 168 |
- } |
|
| 169 |
- return ret.(error) |
|
| 170 |
- } |
|
| 171 |
-} |
|
| 172 |
- |
|
| 173 |
-func Subcmd(output io.Writer, name, signature, description string) *flag.FlagSet {
|
|
| 174 |
- flags := flag.NewFlagSet(name, flag.ContinueOnError) |
|
| 175 |
- flags.SetOutput(output) |
|
| 176 |
- flags.Usage = func() {
|
|
| 177 |
- fmt.Fprintf(output, "\nUsage: docker %s %s\n\n%s\n\n", name, signature, description) |
|
| 178 |
- flags.PrintDefaults() |
|
| 179 |
- } |
|
| 180 |
- return flags |
|
| 181 |
-} |
| 182 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,27 +0,0 @@ |
| 1 |
-package rcli |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "github.com/dotcloud/docker/term" |
|
| 5 |
- "os" |
|
| 6 |
- "os/signal" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-//FIXME: move these function to utils.go (in rcli to avoid import loop) |
|
| 10 |
-func SetRawTerminal() (*term.State, error) {
|
|
| 11 |
- oldState, err := term.MakeRaw(int(os.Stdin.Fd())) |
|
| 12 |
- if err != nil {
|
|
| 13 |
- return nil, err |
|
| 14 |
- } |
|
| 15 |
- c := make(chan os.Signal, 1) |
|
| 16 |
- signal.Notify(c, os.Interrupt) |
|
| 17 |
- go func() {
|
|
| 18 |
- _ = <-c |
|
| 19 |
- term.Restore(int(os.Stdin.Fd()), oldState) |
|
| 20 |
- os.Exit(0) |
|
| 21 |
- }() |
|
| 22 |
- return oldState, err |
|
| 23 |
-} |
|
| 24 |
- |
|
| 25 |
-func RestoreTerminal(state *term.State) {
|
|
| 26 |
- term.Restore(int(os.Stdin.Fd()), state) |
|
| 27 |
-} |
| 28 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,96 @@ |
| 0 |
+package docker |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "testing" |
|
| 4 |
+) |
|
| 5 |
+ |
|
| 6 |
+func TestCreateRm(t *testing.T) {
|
|
| 7 |
+ runtime, err := newTestRuntime() |
|
| 8 |
+ if err != nil {
|
|
| 9 |
+ t.Fatal(err) |
|
| 10 |
+ } |
|
| 11 |
+ defer nuke(runtime) |
|
| 12 |
+ |
|
| 13 |
+ srv := &Server{runtime: runtime}
|
|
| 14 |
+ |
|
| 15 |
+ config, _, err := ParseRun([]string{GetTestImage(runtime).Id, "echo test"})
|
|
| 16 |
+ if err != nil {
|
|
| 17 |
+ t.Fatal(err) |
|
| 18 |
+ } |
|
| 19 |
+ |
|
| 20 |
+ id, _, _, err := srv.ContainerCreate(*config) |
|
| 21 |
+ if err != nil {
|
|
| 22 |
+ t.Fatal(err) |
|
| 23 |
+ } |
|
| 24 |
+ |
|
| 25 |
+ if len(runtime.List()) != 1 {
|
|
| 26 |
+ t.Errorf("Expected 1 container, %v found", len(runtime.List()))
|
|
| 27 |
+ } |
|
| 28 |
+ |
|
| 29 |
+ if err = srv.ContainerDestroy(id, true); err != nil {
|
|
| 30 |
+ t.Fatal(err) |
|
| 31 |
+ } |
|
| 32 |
+ |
|
| 33 |
+ if len(runtime.List()) != 0 {
|
|
| 34 |
+ t.Errorf("Expected 0 container, %v found", len(runtime.List()))
|
|
| 35 |
+ } |
|
| 36 |
+ |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 39 |
+func TestCreateStartRestartStopStartKillRm(t *testing.T) {
|
|
| 40 |
+ runtime, err := newTestRuntime() |
|
| 41 |
+ if err != nil {
|
|
| 42 |
+ t.Fatal(err) |
|
| 43 |
+ } |
|
| 44 |
+ defer nuke(runtime) |
|
| 45 |
+ |
|
| 46 |
+ srv := &Server{runtime: runtime}
|
|
| 47 |
+ |
|
| 48 |
+ config, _, err := ParseRun([]string{GetTestImage(runtime).Id, "/bin/cat"})
|
|
| 49 |
+ if err != nil {
|
|
| 50 |
+ t.Fatal(err) |
|
| 51 |
+ } |
|
| 52 |
+ |
|
| 53 |
+ id, _, _, err := srv.ContainerCreate(*config) |
|
| 54 |
+ if err != nil {
|
|
| 55 |
+ t.Fatal(err) |
|
| 56 |
+ } |
|
| 57 |
+ |
|
| 58 |
+ if len(runtime.List()) != 1 {
|
|
| 59 |
+ t.Errorf("Expected 1 container, %v found", len(runtime.List()))
|
|
| 60 |
+ } |
|
| 61 |
+ |
|
| 62 |
+ err = srv.ContainerStart(id) |
|
| 63 |
+ if err != nil {
|
|
| 64 |
+ t.Fatal(err) |
|
| 65 |
+ } |
|
| 66 |
+ |
|
| 67 |
+ err = srv.ContainerRestart(id, 1) |
|
| 68 |
+ if err != nil {
|
|
| 69 |
+ t.Fatal(err) |
|
| 70 |
+ } |
|
| 71 |
+ |
|
| 72 |
+ err = srv.ContainerStop(id, 1) |
|
| 73 |
+ if err != nil {
|
|
| 74 |
+ t.Fatal(err) |
|
| 75 |
+ } |
|
| 76 |
+ |
|
| 77 |
+ err = srv.ContainerStart(id) |
|
| 78 |
+ if err != nil {
|
|
| 79 |
+ t.Fatal(err) |
|
| 80 |
+ } |
|
| 81 |
+ |
|
| 82 |
+ err = srv.ContainerKill(id) |
|
| 83 |
+ if err != nil {
|
|
| 84 |
+ t.Fatal(err) |
|
| 85 |
+ } |
|
| 86 |
+ |
|
| 87 |
+ if err = srv.ContainerDestroy(id, true); err != nil {
|
|
| 88 |
+ t.Fatal(err) |
|
| 89 |
+ } |
|
| 90 |
+ |
|
| 91 |
+ if len(runtime.List()) != 0 {
|
|
| 92 |
+ t.Errorf("Expected 0 container, %v found", len(runtime.List()))
|
|
| 93 |
+ } |
|
| 94 |
+ |
|
| 95 |
+} |
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"bytes" |
| 5 | 5 |
"errors" |
| 6 | 6 |
"fmt" |
| 7 |
- "github.com/dotcloud/docker/rcli" |
|
| 8 | 7 |
"github.com/dotcloud/docker/term" |
| 9 | 8 |
"index/suffixarray" |
| 10 | 9 |
"io" |
| ... | ... |
@@ -58,9 +57,6 @@ func Debugf(format string, a ...interface{}) {
|
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 | 60 |
fmt.Fprintf(os.Stderr, fmt.Sprintf("[debug] %s:%d %s\n", file, line, format), a...)
|
| 61 |
- if rcli.CLIENT_SOCKET != nil {
|
|
| 62 |
- fmt.Fprintf(rcli.CLIENT_SOCKET, fmt.Sprintf("[debug] %s:%d %s\n", file, line, format), a...)
|
|
| 63 |
- } |
|
| 64 | 61 |
} |
| 65 | 62 |
} |
| 66 | 63 |
|