From 1dae7a25b919dc70798cbab8107809690212cd69 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 31 May 2013 15:53:57 -0700 Subject: [PATCH 01/10] Improve the docker version and docker info commands --- api_params.go | 23 +++++++++++------------ commands.go | 34 +++++++++++++++++++++------------- server.go | 26 ++++++++++++++------------ 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/api_params.go b/api_params.go index 1a24ab2875..e18238b735 100644 --- a/api_params.go +++ b/api_params.go @@ -3,7 +3,7 @@ package docker type ApiHistory struct { Id string Created int64 - CreatedBy string + CreatedBy string `json:",omitempty"` } type ApiImages struct { @@ -14,13 +14,13 @@ type ApiImages struct { } type ApiInfo struct { - Containers int - Version string - Images int Debug bool - GoVersion string - NFd int `json:",omitempty"` - NGoroutines int `json:",omitempty"` + Containers int + Images int + NFd int `json:",omitempty"` + NGoroutines int `json:",omitempty"` + MemoryLimit bool `json:",omitempty"` + SwapLimit bool `json:",omitempty"` } type ApiContainers struct { @@ -43,7 +43,7 @@ type ApiId struct { type ApiRun struct { Id string - Warnings []string + Warnings []string `json:",omitempty"` } type ApiPort struct { @@ -51,10 +51,9 @@ type ApiPort struct { } type ApiVersion struct { - Version string - GitCommit string - MemoryLimit bool - SwapLimit bool + Version string + GitCommit string `json:",omitempty"` + GoVersion string `json:",omitempty"` } type ApiWait struct { diff --git a/commands.go b/commands.go index 6109aebb13..9765b85cab 100644 --- a/commands.go +++ b/commands.go @@ -391,15 +391,14 @@ func (cli *DockerCli) CmdVersion(args ...string) error { utils.Debugf("Error unmarshal: body: %s, err: %s\n", body, err) return err } - fmt.Println("Version:", out.Version) - fmt.Println("Git Commit:", out.GitCommit) - if !out.MemoryLimit { - fmt.Println("WARNING: No memory limit support") + fmt.Println("Client version:", VERSION) + fmt.Println("Server version:", out.Version) + if out.GitCommit != "" { + fmt.Println("Git commit:", out.GitCommit) } - if !out.SwapLimit { - fmt.Println("WARNING: No swap limit support") + if out.GoVersion != "" { + fmt.Println("Go version:", out.GoVersion) } - return nil } @@ -420,14 +419,23 @@ func (cli *DockerCli) CmdInfo(args ...string) error { } var out ApiInfo - err = json.Unmarshal(body, &out) - if err != nil { + if err := json.Unmarshal(body, &out); err != nil { return err } - fmt.Printf("containers: %d\nversion: %s\nimages: %d\nGo version: %s\n", out.Containers, out.Version, out.Images, out.GoVersion) - if out.Debug { - fmt.Println("debug mode enabled") - fmt.Printf("fds: %d\ngoroutines: %d\n", out.NFd, out.NGoroutines) + + fmt.Printf("Containers: %d\n", out.Containers) + fmt.Printf("Images: %d\n", out.Images) + if out.Debug || os.Getenv("DEBUG") != "" { + fmt.Printf("Debug mode (server): %v\n", out.Debug) + fmt.Printf("Debug mode (client): %v\n", os.Getenv("DEBUG") != "") + fmt.Printf("Fds: %d\n", out.NFd) + fmt.Printf("Goroutines: %d\n", out.NGoroutines) + } + if !out.MemoryLimit { + fmt.Println("WARNING: No memory limit support") + } + if !out.SwapLimit { + fmt.Println("WARNING: No swap limit support") } return nil } diff --git a/server.go b/server.go index 90ec79986c..088353c3f7 100644 --- a/server.go +++ b/server.go @@ -17,7 +17,11 @@ import ( ) func (srv *Server) DockerVersion() ApiVersion { - return ApiVersion{VERSION, GIT_COMMIT, srv.runtime.capabilities.MemoryLimit, srv.runtime.capabilities.SwapLimit} + return ApiVersion{ + Version: VERSION, + GitCommit: GIT_COMMIT, + GoVersion: runtime.Version(), + } } func (srv *Server) ContainerKill(name string) error { @@ -187,7 +191,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) { return outs, nil } -func (srv *Server) DockerInfo() ApiInfo { +func (srv *Server) DockerInfo() *ApiInfo { images, _ := srv.runtime.graph.All() var imgcount int if images == nil { @@ -195,17 +199,15 @@ func (srv *Server) DockerInfo() ApiInfo { } else { imgcount = len(images) } - var out ApiInfo - out.Containers = len(srv.runtime.List()) - out.Version = VERSION - out.Images = imgcount - out.GoVersion = runtime.Version() - if os.Getenv("DEBUG") != "" { - out.Debug = true - out.NFd = utils.GetTotalUsedFds() - out.NGoroutines = runtime.NumGoroutine() + return &ApiInfo{ + Containers: len(srv.runtime.List()), + Images: imgcount, + MemoryLimit: srv.runtime.capabilities.MemoryLimit, + SwapLimit: srv.runtime.capabilities.SwapLimit, + Debug: os.Getenv("DEBUG") != "", + NFd: utils.GetTotalUsedFds(), + NGoroutines: runtime.NumGoroutine(), } - return out } func (srv *Server) ImageHistory(name string) ([]ApiHistory, error) { From f41d2ec4d91f2fa1dc479d8bac32113fbb7e987e Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 31 May 2013 15:56:30 -0700 Subject: [PATCH 02/10] Update api docs --- docs/sources/api/docker_remote_api.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/sources/api/docker_remote_api.rst b/docs/sources/api/docker_remote_api.rst index 5056a62a19..e350b9746c 100644 --- a/docs/sources/api/docker_remote_api.rst +++ b/docs/sources/api/docker_remote_api.rst @@ -914,10 +914,12 @@ Display system-wide information { "Containers":11, - "Version":"0.2.2", "Images":16, - "GoVersion":"go1.0.3", - "Debug":false + "Debug":false, + "NFd": 11, + "NGoroutines":21, + "MemoryLimit":true, + "SwapLimit":false } :statuscode 200: no error @@ -943,12 +945,11 @@ Show the docker version information HTTP/1.1 200 OK Content-Type: application/json - + { "Version":"0.2.2", "GitCommit":"5a2a5cc+CHANGES", - "MemoryLimit":true, - "SwapLimit":false + "GoVersion":"go1.0.3" } :statuscode 200: no error From 64f346779fbe4ba9587ec65eedd0e8373f7e29c0 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Sat, 1 Jun 2013 15:51:45 -0700 Subject: [PATCH 03/10] Remove cgo from term --- term/term.go | 12 +++++------ term/termios_linux.go | 50 +++++++++++-------------------------------- 2 files changed, 19 insertions(+), 43 deletions(-) diff --git a/term/term.go b/term/term.go index 290bf174ad..ab90a3ef73 100644 --- a/term/term.go +++ b/term/term.go @@ -8,13 +8,13 @@ import ( ) type Termios struct { - Iflag uintptr - Oflag uintptr - Cflag uintptr - Lflag uintptr + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 Cc [20]byte - Ispeed uintptr - Ospeed uintptr + Ispeed uint32 + Ospeed uint32 } const ( diff --git a/term/termios_linux.go b/term/termios_linux.go index 92f21edde2..31a10a307c 100644 --- a/term/termios_linux.go +++ b/term/termios_linux.go @@ -5,26 +5,6 @@ import ( "unsafe" ) -// #include -// #include -/* -void MakeRaw(int fd) { - struct termios t; - - // FIXME: Handle errors? - ioctl(fd, TCGETS, &t); - - t.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); - t.c_oflag &= ~OPOST; - t.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG); - t.c_cflag &= ~(CSIZE | PARENB); - t.c_cflag |= CS8; - - ioctl(fd, TCSETS, &t); -} -*/ -import "C" - const ( getTermios = syscall.TCGETS setTermios = syscall.TCSETS @@ -35,24 +15,20 @@ const ( // restored. func MakeRaw(fd int) (*State, error) { var oldState State - if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TCGETS, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { + return nil, err + } + + newState := oldState.termios + + newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON) + newState.Oflag &^= syscall.OPOST + newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN) + newState.Cflag &^= (syscall.CSIZE | syscall.PARENB) + newState.Cflag |= syscall.CS8 + + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { return nil, err } - C.MakeRaw(C.int(fd)) return &oldState, nil - - // FIXME: post on goland issues this: very same as the C function bug non-working - - // newState := oldState.termios - - // newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON) - // newState.Oflag &^= OPOST - // newState.Lflag &^= (ECHO | syscall.ECHONL | ICANON | ISIG | IEXTEN) - // newState.Cflag &^= (CSIZE | syscall.PARENB) - // newState.Cflag |= CS8 - - // if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TCSETS, uintptr(unsafe.Pointer(&newState))); err != 0 { - // return nil, err - // } - // return &oldState, nil } From 31eb01ae8aac22a4d768418d3cc4da6f903a8694 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Sat, 1 Jun 2013 15:55:05 -0700 Subject: [PATCH 04/10] Use uintptr instead of int for Fd --- commands.go | 4 ++-- term/term.go | 14 +++++++------- term/termios_linux.go | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/commands.go b/commands.go index 7dd835856f..977ff12839 100644 --- a/commands.go +++ b/commands.go @@ -1414,7 +1414,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in *os.Fi return err }) - if in != nil && setRawTerminal && term.IsTerminal(int(in.Fd())) && os.Getenv("NORAW") == "" { + if in != nil && setRawTerminal && term.IsTerminal(in.Fd()) && os.Getenv("NORAW") == "" { if oldState, err := term.SetRawTerminal(); err != nil { return err } else { @@ -1433,7 +1433,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in *os.Fi return err } - if !term.IsTerminal(int(os.Stdin.Fd())) { + if !term.IsTerminal(os.Stdin.Fd()) { if err := <-sendStdin; err != nil { return err } diff --git a/term/term.go b/term/term.go index ab90a3ef73..4e29361533 100644 --- a/term/term.go +++ b/term/term.go @@ -128,21 +128,21 @@ func SetWinsize(fd uintptr, ws *Winsize) error { } // IsTerminal returns true if the given file descriptor is a terminal. -func IsTerminal(fd int) bool { +func IsTerminal(fd uintptr) bool { var termios Termios - _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(getTermios), uintptr(unsafe.Pointer(&termios))) + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&termios))) return err == 0 } // Restore restores the terminal connected to the given file descriptor to a // previous state. -func Restore(fd int, state *State) error { - _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(setTermios), uintptr(unsafe.Pointer(&state.termios))) +func Restore(fd uintptr, state *State) error { + _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&state.termios))) return err } func SetRawTerminal() (*State, error) { - oldState, err := MakeRaw(int(os.Stdin.Fd())) + oldState, err := MakeRaw(os.Stdin.Fd()) if err != nil { return nil, err } @@ -150,12 +150,12 @@ func SetRawTerminal() (*State, error) { signal.Notify(c, os.Interrupt) go func() { _ = <-c - Restore(int(os.Stdin.Fd()), oldState) + Restore(os.Stdin.Fd(), oldState) os.Exit(0) }() return oldState, err } func RestoreTerminal(state *State) { - Restore(int(os.Stdin.Fd()), state) + Restore(os.Stdin.Fd(), state) } diff --git a/term/termios_linux.go b/term/termios_linux.go index 31a10a307c..7877cb89f8 100644 --- a/term/termios_linux.go +++ b/term/termios_linux.go @@ -13,9 +13,9 @@ const ( // MakeRaw put the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. -func MakeRaw(fd int) (*State, error) { +func MakeRaw(fd uintptr) (*State, error) { var oldState State - if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { return nil, err } @@ -27,7 +27,7 @@ func MakeRaw(fd int) (*State, error) { newState.Cflag &^= (syscall.CSIZE | syscall.PARENB) newState.Cflag |= syscall.CS8 - if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { return nil, err } return &oldState, nil From 3cc0963ad16a5abd67aeba22cefac34a40ac70ef Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Sat, 1 Jun 2013 15:55:52 -0700 Subject: [PATCH 05/10] Remove unused constants --- term/term.go | 88 ---------------------------------------------------- 1 file changed, 88 deletions(-) diff --git a/term/term.go b/term/term.go index 4e29361533..1f3e9d36bb 100644 --- a/term/term.go +++ b/term/term.go @@ -17,94 +17,6 @@ type Termios struct { Ospeed uint32 } -const ( - // Input flags - inpck = 0x010 - istrip = 0x020 - icrnl = 0x100 - ixon = 0x200 - - // Output flags - opost = 0x1 - - // Control flags - cs8 = 0x300 - - // Local flags - icanon = 0x100 - iexten = 0x400 -) - -const ( - HUPCL = 0x4000 - ICANON = 0x100 - ICRNL = 0x100 - IEXTEN = 0x400 - BRKINT = 0x2 - CFLUSH = 0xf - CLOCAL = 0x8000 - CREAD = 0x800 - CS5 = 0x0 - CS6 = 0x100 - CS7 = 0x200 - CS8 = 0x300 - CSIZE = 0x300 - CSTART = 0x11 - CSTATUS = 0x14 - CSTOP = 0x13 - CSTOPB = 0x400 - CSUSP = 0x1a - IGNBRK = 0x1 - IGNCR = 0x80 - IGNPAR = 0x4 - IMAXBEL = 0x2000 - INLCR = 0x40 - INPCK = 0x10 - ISIG = 0x80 - ISTRIP = 0x20 - IUTF8 = 0x4000 - IXANY = 0x800 - IXOFF = 0x400 - IXON = 0x200 - NOFLSH = 0x80000000 - OCRNL = 0x10 - OFDEL = 0x20000 - OFILL = 0x80 - ONLCR = 0x2 - ONLRET = 0x40 - ONOCR = 0x20 - ONOEOT = 0x8 - OPOST = 0x1 - RENB = 0x1000 - PARMRK = 0x8 - PARODD = 0x2000 - - TOSTOP = 0x400000 - VDISCARD = 0xf - VDSUSP = 0xb - VEOF = 0x0 - VEOL = 0x1 - VEOL2 = 0x2 - VERASE = 0x3 - VINTR = 0x8 - VKILL = 0x5 - VLNEXT = 0xe - VMIN = 0x10 - VQUIT = 0x9 - VREPRINT = 0x6 - VSTART = 0xc - VSTATUS = 0x12 - VSTOP = 0xd - VSUSP = 0xa - VT0 = 0x0 - VT1 = 0x10000 - VTDLY = 0x10000 - VTIME = 0x11 - ECHO = 0x00000008 - - PENDIN = 0x20000000 -) - type State struct { termios Termios } From a70dd65964340b5c4ccedf497a2605b13e7ac8a8 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Sat, 1 Jun 2013 16:19:50 -0700 Subject: [PATCH 06/10] Move Termios struct to os specific file --- term/term.go | 10 ---------- term/termios_darwin.go | 32 +++++++++++++++++++++++++++----- term/termios_linux.go | 10 ++++++++++ 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/term/term.go b/term/term.go index 1f3e9d36bb..0cc91ea1b6 100644 --- a/term/term.go +++ b/term/term.go @@ -7,16 +7,6 @@ import ( "unsafe" ) -type Termios struct { - Iflag uint32 - Oflag uint32 - Cflag uint32 - Lflag uint32 - Cc [20]byte - Ispeed uint32 - Ospeed uint32 -} - type State struct { termios Termios } diff --git a/term/termios_darwin.go b/term/termios_darwin.go index 7df54e7828..ac18aab692 100644 --- a/term/termios_darwin.go +++ b/term/termios_darwin.go @@ -8,23 +8,45 @@ import ( const ( getTermios = syscall.TIOCGETA setTermios = syscall.TIOCSETA + + ECHO = 0x00000008 + ONLCR = 0x2 + ISTRIP = 0x20 + INLCR = 0x40 + ISIG = 0x80 + IGNCR = 0x80 + ICANON = 0x100 + ICRNL = 0x100 + IXOFF = 0x400 + IXON = 0x200 ) +type Termios struct { + Iflag uint64 + Oflag uint64 + Cflag uint64 + Lflag uint64 + Cc [20]byte + Ispeed uint64 + Ospeed uint64 +} + // MakeRaw put the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. -func MakeRaw(fd int) (*State, error) { +func MakeRaw(fd uintptr) (*State, error) { var oldState State - if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 { + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { return nil, err } newState := oldState.termios - newState.Iflag &^= ISTRIP | INLCR | IGNCR | IXON | IXOFF + newState.Iflag &^= (ISTRIP | INLCR | IGNCR | IXON | IXOFF) newState.Iflag |= ICRNL newState.Oflag |= ONLCR - newState.Lflag &^= ECHO | ICANON | ISIG - if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(setTermios), uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 { + newState.Lflag &^= (ECHO | ICANON | ISIG) + + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { return nil, err } diff --git a/term/termios_linux.go b/term/termios_linux.go index 7877cb89f8..4a717c84a7 100644 --- a/term/termios_linux.go +++ b/term/termios_linux.go @@ -10,6 +10,16 @@ const ( setTermios = syscall.TCSETS ) +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]byte + Ispeed uint32 + Ospeed uint32 +} + // MakeRaw put the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. From e16c93486d16ac4f3a05f720ee6478b5cef93f10 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 3 Jun 2013 10:19:20 +0000 Subject: [PATCH 07/10] fix Path corruption in 'docker diff' --- changes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes.go b/changes.go index 4c79918887..e50b88758a 100644 --- a/changes.go +++ b/changes.go @@ -65,7 +65,7 @@ func Changes(layers []string, rw string) ([]Change, error) { file := filepath.Base(path) // If there is a whiteout, then the file was removed if strings.HasPrefix(file, ".wh.") { - originalFile := strings.TrimLeft(file, ".wh.") + originalFile := strings.TrimPrefix(file, ".wh.") change.Path = filepath.Join(filepath.Dir(path), originalFile) change.Kind = ChangeDelete } else { From 8243f2510e0ff0af8df18bf0febab819529106d4 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Mon, 3 Jun 2013 06:44:00 -0700 Subject: [PATCH 08/10] Update test to reflect new ApiInfo struct --- api_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api_test.go b/api_test.go index f364c6c895..9121167e10 100644 --- a/api_test.go +++ b/api_test.go @@ -106,8 +106,8 @@ func TestGetInfo(t *testing.T) { if err != nil { t.Fatal(err) } - if infos.Version != VERSION { - t.Errorf("Excepted version %s, %s found", VERSION, infos.Version) + if infos.Images != 1 { + t.Errorf("Excepted images: %d, %d found", 1, infos.Images) } } From 1ce4ba6c9f381f7931615644675b0cad33e74492 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 3 Jun 2013 15:33:29 +0000 Subject: [PATCH 09/10] remove check on login --- commands.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/commands.go b/commands.go index 9f3168ac06..ddb2c1a52b 100644 --- a/commands.go +++ b/commands.go @@ -739,12 +739,6 @@ func (cli *DockerCli) CmdPull(args ...string) error { remote = remoteParts[0] } - if strings.Contains(remote, "/") { - if _, err := cli.checkIfLogged(true, "pull"); err != nil { - return err - } - } - v := url.Values{} v.Set("fromImage", remote) v.Set("tag", *tag) From 71b1657e8d22b6dfa0a426f6244c6a3101f66bc4 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 3 Jun 2013 17:02:57 +0000 Subject: [PATCH 10/10] added test --- container_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/container_test.go b/container_test.go index 3ed1763a3e..117f0f3eb3 100644 --- a/container_test.go +++ b/container_test.go @@ -217,6 +217,37 @@ func TestDiff(t *testing.T) { t.Fatalf("/etc/passwd should not be present in the diff after commit.") } } + + // Create a new containere + container3, err := builder.Create( + &Config{ + Image: GetTestImage(runtime).Id, + Cmd: []string{"rm", "/bin/httpd"}, + }, + ) + if err != nil { + t.Fatal(err) + } + defer runtime.Destroy(container3) + + if err := container3.Run(); err != nil { + t.Fatal(err) + } + + // Check the changelog + c, err = container3.Changes() + if err != nil { + t.Fatal(err) + } + success = false + for _, elem := range c { + if elem.Path == "/bin/httpd" && elem.Kind == 2 { + success = true + } + } + if !success { + t.Fatalf("/bin/httpd should be present in the diff after commit.") + } } func TestCommitAutoRun(t *testing.T) {