diff --git a/components/engine/CHANGELOG.md b/components/engine/CHANGELOG.md new file mode 100644 index 0000000000..e7c7742076 --- /dev/null +++ b/components/engine/CHANGELOG.md @@ -0,0 +1,77 @@ +# Changelog + +## 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.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 documentation + - Add Vagrant support with Vagrantfile + - Add unit tests + - Add repository/tags to ease image management + - Improve the layer implementation diff --git a/components/engine/commands.go b/components/engine/commands.go index b0440a9766..b2f49a080a 100644 --- a/components/engine/commands.go +++ b/components/engine/commands.go @@ -18,7 +18,7 @@ import ( "unicode" ) -const VERSION = "0.1.7" +const VERSION = "0.1.8" var ( GIT_COMMIT string @@ -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() } diff --git a/components/engine/container.go b/components/engine/container.go index c2c6fddd40..bac0951da4 100644 --- a/components/engine/container.go +++ b/components/engine/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() @@ -588,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 } @@ -600,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 @@ -617,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() } @@ -629,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 { diff --git a/components/engine/docs/sources/concepts/buildingblocks.rst b/components/engine/docs/sources/concepts/buildingblocks.rst index 0fc859418f..d422e6eef3 100644 --- a/components/engine/docs/sources/concepts/buildingblocks.rst +++ b/components/engine/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 diff --git a/components/engine/docs/sources/examples/python_web_app.rst b/components/engine/docs/sources/examples/python_web_app.rst index 7b7edc05e3..33caa52c1e 100644 --- a/components/engine/docs/sources/examples/python_web_app.rst +++ b/components/engine/docs/sources/examples/python_web_app.rst @@ -49,7 +49,7 @@ Save the changed we just made in the container to a new image called "_/builds/g WEB_WORKER=$(docker run -d -p 5000 $BUILD_IMG /usr/local/bin/runapp) - **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon. - **"-p 5000"* the web app is going to listen on this port, so it must be mapped from the container to the host system. +- **"-p 5000"** the web app is going to listen on this port, so it must be mapped from the container to the host system. - **"$BUILD_IMG"** is the image we want to run the command inside of. - **/usr/local/bin/runapp** is the command which starts the web app. diff --git a/components/engine/docs/sources/gettingstarted/index.html b/components/engine/docs/sources/gettingstarted/index.html index 1022879071..96175d6dec 100644 --- a/components/engine/docs/sources/gettingstarted/index.html +++ b/components/engine/docs/sources/gettingstarted/index.html @@ -71,40 +71,38 @@

Installing on Ubuntu

- Requirements + +

Requirements

  1. -

    Add the Ubuntu PPA (Personal Package Archive) sources to your apt sources list. Copy and - paste the following lines at once.

    +

    Install dependencies

    + The linux-image-extra package is only needed on standard Ubuntu EC2 AMIs in order to install the aufs kernel module. +
    sudo apt-get install linux-image-extra-`uname -r`
    + +
  2. +
  3. +

    Install Docker

    +

    Add the Ubuntu PPA (Personal Package Archive) sources to your apt sources list, update and install.

    +

    You may see some warnings that the GPG keys cannot be verified.

    sudo sh -c "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >> /etc/apt/sources.list"
    - -
  4. -
  5. -

    Update your sources. You will see a warning that GPG signatures cannot be verified.

    - -
    sudo apt-get update
    -
    -
  6. -
  7. -

    Now install it, you will see another warning that the package cannot be authenticated. Confirm install.

    - -
    sudo apt-get install lxc-docker
    + +
  8. Run!

    -
    docker
    +
    docker run -i -t ubuntu /bin/bash
  9. Continue with the Hello world example. diff --git a/components/engine/docs/sources/installation/archlinux.rst b/components/engine/docs/sources/installation/archlinux.rst index 595dc1809c..db013c6cb9 100644 --- a/components/engine/docs/sources/installation/archlinux.rst +++ b/components/engine/docs/sources/installation/archlinux.rst @@ -44,6 +44,7 @@ new kernel will be compiled and this can take quite a while. yaourt -S lxc-docker-git + Starting Docker --------------- @@ -56,10 +57,7 @@ There is a systemd service unit created for docker. To start the docker service sudo systemctl start docker -<<<<<<< HEAD -======= ->>>>>>> dotcloud/master To start on system boot: :: diff --git a/components/engine/docs/sources/installation/binaries.rst b/components/engine/docs/sources/installation/binaries.rst index bf83a5bc88..3428f9f279 100644 --- a/components/engine/docs/sources/installation/binaries.rst +++ b/components/engine/docs/sources/installation/binaries.rst @@ -1,56 +1,53 @@ -.. _ubuntu_linux: +.. _binaries: -Ubuntu Linux -============ +Binaries +======== **Please note this project is currently under heavy development. It should not be used in production.** - -Installing on Ubuntu 12.04 and 12.10 - Right now, the officially supported distributions are: -Ubuntu 12.04 (precise LTS) -Ubuntu 12.10 (quantal) -Docker probably works on other distributions featuring a recent kernel, the AUFS patch, and up-to-date lxc. However this has not been tested. +- Ubuntu 12.04 (precise LTS) (64-bit) +- Ubuntu 12.10 (quantal) (64-bit) + Install dependencies: --------------------- :: - sudo apt-get install lxc wget bsdtar curl + sudo apt-get install lxc bsdtar sudo apt-get install linux-image-extra-`uname -r` The linux-image-extra package is needed on standard Ubuntu EC2 AMIs in order to install the aufs kernel module. -Install the latest docker binary: +Install the docker binary: :: - wget http://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-master.tgz + wget http://get.docker.io/builds/Linux/x86_64/docker-master.tgz tar -xf docker-master.tgz + sudo cp ./docker-master /usr/local/bin + +Note: docker currently only supports 64-bit Linux hosts. + + +Run the docker daemon +--------------------- + +:: + + sudo docker -d & + Run your first container! +------------------------- :: - cd docker-master - -:: - - sudo ./docker run -i -t base /bin/bash + docker run -i -t ubuntu /bin/bash -To run docker as a daemon, in the background, and allow non-root users to run ``docker`` start -docker -d - -:: - - sudo ./docker -d & - - -Consider adding docker to your PATH for simplicity. Continue with the :ref:`hello_world` example. \ No newline at end of file diff --git a/components/engine/docs/sources/installation/index.rst b/components/engine/docs/sources/installation/index.rst index f9a59b0ad6..0726d9b715 100644 --- a/components/engine/docs/sources/installation/index.rst +++ b/components/engine/docs/sources/installation/index.rst @@ -13,6 +13,7 @@ Contents: :maxdepth: 1 ubuntulinux + binaries archlinux vagrant windows diff --git a/components/engine/docs/sources/installation/macos.rst b/components/engine/docs/sources/installation/macos.rst deleted file mode 100644 index 09eca22b92..0000000000 --- a/components/engine/docs/sources/installation/macos.rst +++ /dev/null @@ -1,66 +0,0 @@ - -Mac OS X and other linux -======================== - - Please note this is a community contributed installation path. The only 'official' installation is using the :ref:`ubuntu_linux` installation path. This version - may be out of date because it depends on some binaries to be updated and published - - -Requirements ------------- - -We currently rely on some Ubuntu-linux specific packages, this will change in the future, but for now we provide a -streamlined path to install Virtualbox with a Ubuntu 12.10 image using Vagrant. - -1. Install virtualbox from https://www.virtualbox.org/ (or use your package manager) -2. Install vagrant from http://www.vagrantup.com/ (or use your package manager) -3. Install git if you had not installed it before, check if it is installed by running - ``git`` in a terminal window - -We recommend having at least about 2Gb of free disk space and 2Gb RAM (or more). - -Installation ------------- - -1. Fetch the docker sources - -.. code-block:: bash - - git clone https://github.com/dotcloud/docker.git - -2. Run vagrant from the sources directory - -.. code-block:: bash - - vagrant up - -Vagrant will: - -* Download the Quantal64 base ubuntu virtual machine image from get.docker.io/ -* Boot this image in virtualbox - -Then it will use Puppet to perform an initial setup in this machine: - -* Download & untar the most recent docker binary tarball to vagrant homedir. -* Debootstrap to /var/lib/docker/images/ubuntu. -* Install & run dockerd as service. -* Put docker in /usr/local/bin. -* Put latest Go toolchain in /usr/local/go. - -You now have a Ubuntu Virtual Machine running with docker pre-installed. - -To access the VM and use Docker, Run ``vagrant ssh`` from the same directory as where you ran -``vagrant up``. Vagrant will make sure to connect you to the correct VM. - -.. code-block:: bash - - vagrant ssh - -Now you are in the VM, run docker - -.. code-block:: bash - - docker - - -Continue with the :ref:`hello_world` example. diff --git a/components/engine/docs/sources/installation/ubuntulinux.rst b/components/engine/docs/sources/installation/ubuntulinux.rst index 5f1ab39229..ebf9876e22 100644 --- a/components/engine/docs/sources/installation/ubuntulinux.rst +++ b/components/engine/docs/sources/installation/ubuntulinux.rst @@ -6,17 +6,31 @@ Ubuntu Linux **Please note this project is currently under heavy development. It should not be used in production.** -Docker is now available as a Ubuntu PPA (Personal Package Archive), +Right now, the officially supported distributions are: + +- Ubuntu 12.04 (precise LTS) (64-bit) +- Ubuntu 12.10 (quantal) (64-bit) + +Dependencies +------------ + +The linux-image-extra package is only needed on standard Ubuntu EC2 AMIs in order to install the aufs kernel module. + +.. code-block:: bash + + sudo apt-get install linux-image-extra-`uname -r` + + +Installation +------------ + +Docker is available as a Ubuntu PPA (Personal Package Archive), `hosted on launchpad `_ which makes installing Docker on Ubuntu very easy. -**The Requirements** - -* Ubuntu 12.04 (LTS) or Ubuntu 12.10 -* **64-bit Operating system** -Add the custom package sources to your apt sources list. Copy and paste both the following lines at once. +Add the custom package sources to your apt sources list. Copy and paste the following lines at once. .. code-block:: bash diff --git a/components/engine/docs/sources/installation/vagrant.rst b/components/engine/docs/sources/installation/vagrant.rst index 67d1f22813..465a6c3388 100644 --- a/components/engine/docs/sources/installation/vagrant.rst +++ b/components/engine/docs/sources/installation/vagrant.rst @@ -1,8 +1,8 @@ .. _install_using_vagrant: -Install using Vagrant -===================== +Using Vagrant +============= Please note this is a community contributed installation path. The only 'official' installation is using the :ref:`ubuntu_linux` installation path. This version may sometimes be out of date. @@ -27,37 +27,44 @@ Spin it up 1. Fetch the docker sources (this includes the Vagrantfile for machine setup). -.. code-block:: bash + .. code-block:: bash - git clone https://github.com/dotcloud/docker.git + git clone https://github.com/dotcloud/docker.git 2. Run vagrant from the sources directory -.. code-block:: bash + .. code-block:: bash - vagrant up + vagrant up -Vagrant will: + Vagrant will: -* Download the 'official' Precise64 base ubuntu virtual machine image from vagrantup.com -* Boot this image in virtualbox -* Add the `Docker PPA sources `_ to /etc/apt/sources.lst -* Update your sources -* Install lxc-docker + * Download the 'official' Precise64 base ubuntu virtual machine image from vagrantup.com + * Boot this image in virtualbox + * Add the `Docker PPA sources `_ to /etc/apt/sources.lst + * Update your sources + * Install lxc-docker -You now have a Ubuntu Virtual Machine running with docker pre-installed. + You now have a Ubuntu Virtual Machine running with docker pre-installed. + +Connect +------- To access the VM and use Docker, Run ``vagrant ssh`` from the same directory as where you ran ``vagrant up``. Vagrant will connect you to the correct VM. .. code-block:: bash - vagrant ssh + vagrant ssh + +Run +----- Now you are in the VM, run docker .. code-block:: bash - docker + docker + Continue with the :ref:`hello_world` example. diff --git a/components/engine/hack/dockerbuilder/Dockerfile b/components/engine/hack/dockerbuilder/Dockerfile new file mode 100644 index 0000000000..8ef1e40b9d --- /dev/null +++ b/components/engine/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/components/engine/hack/dockerbuilder/dockerbuilder b/components/engine/hack/dockerbuilder/dockerbuilder new file mode 100644 index 0000000000..8ad0573800 --- /dev/null +++ b/components/engine/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/components/engine/hack/dockerbuilder/s3cfg b/components/engine/hack/dockerbuilder/s3cfg new file mode 100644 index 0000000000..963af7d365 --- /dev/null +++ b/components/engine/hack/dockerbuilder/s3cfg @@ -0,0 +1,3 @@ +[default] +access_key = $AWS_ID +secret_key = $AWS_KEY diff --git a/components/engine/runtime.go b/components/engine/runtime.go index 1dfc22d632..d6eb0f3c91 100644 --- a/components/engine/runtime.go +++ b/components/engine/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 } diff --git a/components/engine/runtime_test.go b/components/engine/runtime_test.go index c43e8641ea..3964549412 100644 --- a/components/engine/runtime_test.go +++ b/components/engine/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"], diff --git a/components/engine/utils.go b/components/engine/utils.go index 5974b7df3b..8bcf38367b 100644 --- a/components/engine/utils.go +++ b/components/engine/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 {