From 0b60829df795bc5178feb8f266b1f7e35a91f6da Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Mon, 22 Apr 2013 14:41:30 -0700 Subject: [PATCH 01/11] Add initial changelog --- CHANGELOG.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..66d052e6e2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +## 0.2.0 (dev) + - Fix Vagrant in windows and OSX + - Fix TTY behavior + - Fix attach/detach/run behavior + - Fix memory/fds leaks + - Fix various race conditions + - Fix `docker diff` for removed files + - Fix `docker stop` for ghost containers + - Fix lxc 0.9 compatibility + - Implement an escape sequence `C-p C-q` in order to detach containers in tty mode + - Implement `-a stdin` in order to write on container's stdin while retrieving its ID + - Implement the possiblity to choose the publicly exposed port + - Implement progress bar for registry push/pull + - Improve documentation + - Improve `docker rmi` in order to remove images by name + - Shortened containers and images IDs + - Add cgroup capabilities detection + - Automatically try to load AUFS module + - Automatically create and configure a bridge `dockbr0` + - Remove the standalone mode + +## 0.1.0 (03/23/2013) + - Open-source the project + - Implement registry in order to push/pull images + - Fix termcaps on Linux + - Add the documentation + - Add Vagrant support with Vagrantfile + - Add unit tests + - Add repository/tags to ease the image management + - Improve the layer implementation From 82848d415866d08121bb52857e7d7b1d2a952c0c Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 19 Apr 2013 12:08:43 -0700 Subject: [PATCH 02/11] Allow to wait on container even after docker server restarts using lxc-info --- container.go | 34 ++++++++++++++++++++++++++++++---- runtime.go | 15 +++++++++------ 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/container.go b/container.go index c2c6fddd40..91c5806ecb 100644 --- a/container.go +++ b/container.go @@ -530,16 +530,42 @@ func (container *Container) releaseNetwork() { container.NetworkSettings = &NetworkSettings{} } +// FIXME: replace this with a control socket within docker-init +func (container *Container) waitLxc() error { + for { + if output, err := exec.Command("lxc-info", "-n", container.Id).CombinedOutput(); err != nil { + return err + } else { + if !strings.Contains(string(output), "RUNNING") { + return nil + } + } + time.Sleep(500 * time.Millisecond) + } + return nil +} + func (container *Container) monitor() { // Wait for the program to exit Debugf("Waiting for process") - if err := container.cmd.Wait(); err != nil { - // Discard the error as any signals or non 0 returns will generate an error - Debugf("%s: Process: %s", container.Id, err) + + // If the command does not exists, try to wait via lxc + if container.cmd == nil { + if err := container.waitLxc(); err != nil { + Debugf("%s: Process: %s", container.Id, err) + } + } else { + if err := container.cmd.Wait(); err != nil { + // Discard the error as any signals or non 0 returns will generate an error + Debugf("%s: Process: %s", container.Id, err) + } } Debugf("Process finished") - exitCode := container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() + var exitCode int = -1 + if container.cmd != nil { + exitCode = container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus() + } // Cleanup container.releaseNetwork() diff --git a/runtime.go b/runtime.go index b894a2cdaf..1b4fceced7 100644 --- a/runtime.go +++ b/runtime.go @@ -184,12 +184,6 @@ func (runtime *Runtime) Register(container *Container) error { } } - // If the container is not running or just has been flagged not running - // then close the wait lock chan (will be reset upon start) - if !container.State.Running { - close(container.waitLock) - } - // Even if not running, we init the lock (prevents races in start/stop/kill) container.State.initLock() @@ -207,6 +201,15 @@ func (runtime *Runtime) Register(container *Container) error { // done runtime.containers.PushBack(container) runtime.idIndex.Add(container.Id) + + // If the container is not running or just has been flagged not running + // then close the wait lock chan (will be reset upon start) + if !container.State.Running { + close(container.waitLock) + } else { + container.allocateNetwork() + go container.monitor() + } return nil } From d440782e17d384d52c813f93cd53d2d8a15fd13a Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 19 Apr 2013 12:12:30 -0700 Subject: [PATCH 03/11] Allow to kill container after docker server restarts --- container.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/container.go b/container.go index 91c5806ecb..1f60e08a9d 100644 --- a/container.go +++ b/container.go @@ -614,7 +614,7 @@ func (container *Container) monitor() { } func (container *Container) kill() error { - if !container.State.Running || container.cmd == nil { + if !container.State.Running { return nil } @@ -626,6 +626,9 @@ func (container *Container) kill() error { // 2. Wait for the process to die, in last resort, try to kill the process directly if err := container.WaitTimeout(10 * time.Second); err != nil { + if container.cmd == nil { + return fmt.Errorf("lxc-kill failed, impossible to kill the container %s", container.Id) + } log.Printf("Container %s failed to exit within 10 seconds of lxc SIGKILL - trying direct SIGKILL", container.Id) if err := container.cmd.Process.Kill(); err != nil { return err From f926ed182f908aba20980202becfcdbe2d1e9c34 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 19 Apr 2013 12:21:39 -0700 Subject: [PATCH 04/11] Allow to kill/stop ghosts --- container.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/container.go b/container.go index 1f60e08a9d..bac0951da4 100644 --- a/container.go +++ b/container.go @@ -646,9 +646,6 @@ func (container *Container) Kill() error { if !container.State.Running { return nil } - if container.State.Ghost { - return fmt.Errorf("Can't kill ghost container") - } return container.kill() } @@ -658,9 +655,6 @@ func (container *Container) Stop(seconds int) error { if !container.State.Running { return nil } - if container.State.Ghost { - return fmt.Errorf("Can't stop ghost container") - } // 1. Send a SIGTERM if output, err := exec.Command("lxc-kill", "-n", container.Id, "15").CombinedOutput(); err != nil { From b76d63cb0c97aacec6d81c07108d2a573fb8af05 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Fri, 19 Apr 2013 14:18:03 -0700 Subject: [PATCH 05/11] Forbid attach to ghost --- commands.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commands.go b/commands.go index b0440a9766..de814d6648 100644 --- a/commands.go +++ b/commands.go @@ -836,6 +836,10 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout rcli.DockerConn, args . return fmt.Errorf("No such container: %s", name) } + if container.State.Ghost { + return fmt.Errorf("Impossible to attach to a ghost container") + } + if container.Config.Tty { stdout.SetOptionRawTerminal() } From 97badbd29e15296b2b4cb55b01246f658c5e9de6 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 22 Apr 2013 22:04:57 -0700 Subject: [PATCH 06/11] Bumped version to 0.1.8 --- commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands.go b/commands.go index b0440a9766..85daeb6b8f 100644 --- a/commands.go +++ b/commands.go @@ -18,7 +18,7 @@ import ( "unicode" ) -const VERSION = "0.1.7" +const VERSION = "0.1.8" var ( GIT_COMMIT string From 82b8f7a565ec1fdd82644ef715767ea93d95a0b0 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 22 Apr 2013 22:29:12 -0700 Subject: [PATCH 07/11] hack/dockerbuilder: a standard build environment for building and uploading official binary builds of docker... inside docker --- hack/dockerbuilder/Dockerfile | 11 +++++++++++ hack/dockerbuilder/dockerbuilder | 29 +++++++++++++++++++++++++++++ hack/dockerbuilder/s3cfg | 3 +++ 3 files changed, 43 insertions(+) create mode 100644 hack/dockerbuilder/Dockerfile create mode 100644 hack/dockerbuilder/dockerbuilder create mode 100644 hack/dockerbuilder/s3cfg diff --git a/hack/dockerbuilder/Dockerfile b/hack/dockerbuilder/Dockerfile new file mode 100644 index 0000000000..8ef1e40b9d --- /dev/null +++ b/hack/dockerbuilder/Dockerfile @@ -0,0 +1,11 @@ +# This will build a container capable of producing an official binary build of docker and +# uploading it to S3 +from ubuntu:12.10 +run apt-get update +run RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q s3cmd +run RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang +run RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q git +run RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q build-essential +copy dockerbuilder /usr/local/bin/dockerbuilder +copy s3cfg /.s3cfg +# run $img dockerbuilder $REVISION_OR_TAG $S3_ID $S3_KEY diff --git a/hack/dockerbuilder/dockerbuilder b/hack/dockerbuilder/dockerbuilder new file mode 100644 index 0000000000..8ad0573800 --- /dev/null +++ b/hack/dockerbuilder/dockerbuilder @@ -0,0 +1,29 @@ +#!/bin/sh +set -x +set -e + +PACKAGE=github.com/dotcloud/docker + +if [ $# -lt 3 ]; then + echo "Usage: $0 REVISION AWS_ID AWS_KEY" + exit 1 +fi + +export REVISION=$1 AWS_ID=$2 AWS_KEY=$3 + + +export PATH=/usr/local/bin:$PATH + +mkdir -p /go/src/$PACKAGE +git clone "https://$PACKAGE" /go/src/$PACKAGE +cd /go/src/$PACKAGE +git checkout $REVISION + +# FIXME: checkout to specific revision + +BUILDDIR=/tmp/docker-$REVISION +mkdir -p $BUILDDIR +(cd docker && go get && go build -o $BUILDDIR/docker) + +tar -f /tmp/docker.tgz -C $(dirname $BUILDDIR) -zc $(basename $BUILDDIR) +s3cmd -P put /tmp/docker.tgz s3://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-$REVISION.tgz diff --git a/hack/dockerbuilder/s3cfg b/hack/dockerbuilder/s3cfg new file mode 100644 index 0000000000..963af7d365 --- /dev/null +++ b/hack/dockerbuilder/s3cfg @@ -0,0 +1,3 @@ +[default] +access_key = $AWS_ID +secret_key = $AWS_KEY From e413340723871ad2d7a03822ca06993ee3c0a4bc Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 23 Apr 2013 01:09:29 -0600 Subject: [PATCH 08/11] Update FindCgroupMountpoint to be more forgiving On Gentoo, the memory cgroup is mounted at /sys/fs/cgroup/memory, but the mount line looks like the following: memory on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) (note that the first word on the line is "memory", not "cgroup", but the other essentials are there, namely the type of cgroup and the memory mount option) --- utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.go b/utils.go index 5974b7df3b..8bcf38367b 100644 --- a/utils.go +++ b/utils.go @@ -442,7 +442,7 @@ func FindCgroupMountpoint(cgroupType string) (string, error) { return "", err } - reg := regexp.MustCompile(`^cgroup on (.*) type cgroup \(.*` + cgroupType + `[,\)]`) + reg := regexp.MustCompile(`^.* on (.*) type cgroup \(.*` + cgroupType + `[,\)]`) for _, line := range strings.Split(string(output), "\n") { r := reg.FindStringSubmatch(line) if len(r) == 2 { From 4f6cc5c7330a7389d558dece2e432f13249bd565 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Tue, 23 Apr 2013 00:30:18 -0700 Subject: [PATCH 09/11] Completed Changelog for all past versions --- CHANGELOG.md | 93 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66d052e6e2..e7c7742076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,32 +1,77 @@ # Changelog -## 0.2.0 (dev) - - Fix Vagrant in windows and OSX - - Fix TTY behavior - - Fix attach/detach/run behavior - - Fix memory/fds leaks - - Fix various race conditions - - Fix `docker diff` for removed files - - Fix `docker stop` for ghost containers - - Fix lxc 0.9 compatibility - - Implement an escape sequence `C-p C-q` in order to detach containers in tty mode - - Implement `-a stdin` in order to write on container's stdin while retrieving its ID - - Implement the possiblity to choose the publicly exposed port - - Implement progress bar for registry push/pull - - Improve documentation - - Improve `docker rmi` in order to remove images by name - - Shortened containers and images IDs - - Add cgroup capabilities detection - - Automatically try to load AUFS module - - Automatically create and configure a bridge `dockbr0` - - Remove the standalone mode +## 0.1.8 (2013-04-22) + - Dynamically detect cgroup capabilities + - Issue stability warning on kernels <3.8 + - 'docker push' buffers on disk instead of memory + - Fix 'docker diff' for removed files + - Fix 'docker stop' for ghost containers + - Fix handling of pidfile + - Various bugfixes and stability improvements -## 0.1.0 (03/23/2013) - - Open-source the project +## 0.1.7 (2013-04-18) + - Container ports are available on localhost + - 'docker ps' shows allocated TCP ports + - Contributors can run 'make hack' to start a continuous integration VM + - Streamline ubuntu packaging & uploading + - Various bugfixes and stability improvements + +## 0.1.6 (2013-04-17) + - Record the author an image with 'docker commit -author' + +## 0.1.5 (2013-04-17) + - Disable standalone mode + - Use a custom DNS resolver with 'docker -d -dns' + - Detect ghost containers + - Improve diagnosis of missing system capabilities + - Allow disabling memory limits at compile time + - Add debian packaging + - Documentation: installing on Arch Linux + - Documentation: running Redis on docker + - Fixed lxc 0.9 compatibility + - Automatically load aufs module + - Various bugfixes and stability improvements + +## 0.1.4 (2013-04-09) + - Full support for TTY emulation + - Detach from a TTY session with the escape sequence `C-p C-q` + - Various bugfixes and stability improvements + - Minor UI improvements + - Automatically create our own bridge interface 'docker0' + +## 0.1.3 (2013-04-04) + - Choose TCP frontend port with '-p :PORT' + - Layer format is versioned + - Major reliability improvements to the process manager + - Various bugfixes and stability improvements + +## 0.1.2 (2013-04-03) + - Set container hostname with 'docker run -h' + - Selective attach at run with 'docker run -a [stdin[,stdout[,stderr]]]' + - Various bugfixes and stability improvements + - UI polish + - Progress bar on push/pull + - Use XZ compression by default + - Make IP allocator lazy + +## 0.1.1 (2013-03-31) + - Display shorthand IDs for convenience + - Stabilize process management + - Layers can include a commit message + - Simplified 'docker attach' + - Fixed support for re-attaching + - Various bugfixes and stability improvements + - Auto-download at run + - Auto-login on push + - Beefed up documentation + +## 0.1.0 (2013-03-23) + - First release - Implement registry in order to push/pull images + - TCP port allocation - Fix termcaps on Linux - - Add the documentation + - Add documentation - Add Vagrant support with Vagrantfile - Add unit tests - - Add repository/tags to ease the image management + - Add repository/tags to ease image management - Improve the layer implementation From cbc4eccd50ac80ff6e21caeb386328f8a5fcfaff Mon Sep 17 00:00:00 2001 From: Alexey Shamrin Date: Tue, 23 Apr 2013 12:52:55 +0400 Subject: [PATCH 10/11] fixed typo in buildingblocks.rst --- docs/sources/concepts/buildingblocks.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/concepts/buildingblocks.rst b/docs/sources/concepts/buildingblocks.rst index 0fc859418f..d422e6eef3 100644 --- a/docs/sources/concepts/buildingblocks.rst +++ b/docs/sources/concepts/buildingblocks.rst @@ -10,7 +10,7 @@ Building blocks Images ------ -An original container image. These are stored on disk and are comparable with what you normally expect from a stoppped virtual machine image. Images are stored (and retrieved from) repository +An original container image. These are stored on disk and are comparable with what you normally expect from a stopped virtual machine image. Images are stored (and retrieved from) repository Images are stored on your local file system under /var/lib/docker/images From 73da7a12e7d6846a12571e6eac1f16502219c9d4 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Tue, 23 Apr 2013 10:12:46 -0700 Subject: [PATCH 11/11] Increased timeout in TCP port allocation test to pass on slower machines --- runtime_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime_test.go b/runtime_test.go index c43e8641ea..3964549412 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -273,7 +273,7 @@ func TestAllocatePortLocalhost(t *testing.T) { t.Fatal(err) } defer container.Kill() - time.Sleep(300 * time.Millisecond) // Wait for the container to run + time.Sleep(600 * time.Millisecond) // Wait for the container to run conn, err := net.Dial("tcp", fmt.Sprintf( "localhost:%s", container.NetworkSettings.PortMapping["5555"],