Browse code

Fixed remaining issues and conflicts created by last merge.

Thatcher Peskens authored on 2013/04/24 04:04:53
Showing 18 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,77 @@
0
+# Changelog
1
+
2
+## 0.1.8 (2013-04-22)
3
+ - Dynamically detect cgroup capabilities
4
+ - Issue stability warning on kernels <3.8
5
+ - 'docker push' buffers on disk instead of memory
6
+ - Fix 'docker diff' for removed files
7
+ - Fix 'docker stop' for ghost containers 
8
+ - Fix handling of pidfile
9
+ - Various bugfixes and stability improvements
10
+
11
+## 0.1.7 (2013-04-18)
12
+ - Container ports are available on localhost
13
+ - 'docker ps' shows allocated TCP ports
14
+ - Contributors can run 'make hack' to start a continuous integration VM
15
+ - Streamline ubuntu packaging & uploading
16
+ - Various bugfixes and stability improvements
17
+
18
+## 0.1.6 (2013-04-17)
19
+ - Record the author an image with 'docker commit -author'
20
+
21
+## 0.1.5 (2013-04-17)
22
+ - Disable standalone mode
23
+ - Use a custom DNS resolver with 'docker -d -dns'
24
+ - Detect ghost containers
25
+ - Improve diagnosis of missing system capabilities
26
+ - Allow disabling memory limits at compile time
27
+ - Add debian packaging
28
+ - Documentation: installing on Arch Linux 
29
+ - Documentation: running Redis on docker
30
+ - Fixed lxc 0.9 compatibility
31
+ - Automatically load aufs module
32
+ - Various bugfixes and stability improvements
33
+
34
+## 0.1.4 (2013-04-09)
35
+ - Full support for TTY emulation
36
+ - Detach from a TTY session with the escape sequence `C-p C-q`
37
+ - Various bugfixes and stability improvements
38
+ - Minor UI improvements
39
+ - Automatically create our own bridge interface 'docker0'
40
+
41
+## 0.1.3 (2013-04-04)
42
+ - Choose TCP frontend port with '-p :PORT'
43
+ - Layer format is versioned
44
+ - Major reliability improvements to the process manager
45
+ - Various bugfixes and stability improvements
46
+
47
+## 0.1.2 (2013-04-03)
48
+ - Set container hostname with 'docker run -h'
49
+ - Selective attach at run with 'docker run -a [stdin[,stdout[,stderr]]]'
50
+ - Various bugfixes and stability improvements
51
+ - UI polish
52
+ - Progress bar on push/pull
53
+ - Use XZ compression by default
54
+ - Make IP allocator lazy
55
+
56
+## 0.1.1 (2013-03-31)
57
+ - Display shorthand IDs for convenience
58
+ - Stabilize process management
59
+ - Layers can include a commit message
60
+ - Simplified 'docker attach'
61
+ - Fixed support for re-attaching
62
+ - Various bugfixes and stability improvements
63
+ - Auto-download at run
64
+ - Auto-login on push
65
+ - Beefed up documentation
66
+
67
+## 0.1.0 (2013-03-23)
68
+ - First release
69
+ - Implement registry in order to push/pull images
70
+ - TCP port allocation
71
+ - Fix termcaps on Linux
72
+ - Add documentation
73
+ - Add Vagrant support with Vagrantfile
74
+ - Add unit tests
75
+ - Add repository/tags to ease image management
76
+ - Improve the layer implementation
... ...
@@ -18,7 +18,7 @@ import (
18 18
 	"unicode"
19 19
 )
20 20
 
21
-const VERSION = "0.1.7"
21
+const VERSION = "0.1.8"
22 22
 
23 23
 var (
24 24
 	GIT_COMMIT string
... ...
@@ -836,6 +836,10 @@ func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout rcli.DockerConn, args .
836 836
 		return fmt.Errorf("No such container: %s", name)
837 837
 	}
838 838
 
839
+	if container.State.Ghost {
840
+		return fmt.Errorf("Impossible to attach to a ghost container")
841
+	}
842
+
839 843
 	if container.Config.Tty {
840 844
 		stdout.SetOptionRawTerminal()
841 845
 	}
... ...
@@ -530,16 +530,42 @@ func (container *Container) releaseNetwork() {
530 530
 	container.NetworkSettings = &NetworkSettings{}
531 531
 }
532 532
 
533
+// FIXME: replace this with a control socket within docker-init
534
+func (container *Container) waitLxc() error {
535
+	for {
536
+		if output, err := exec.Command("lxc-info", "-n", container.Id).CombinedOutput(); err != nil {
537
+			return err
538
+		} else {
539
+			if !strings.Contains(string(output), "RUNNING") {
540
+				return nil
541
+			}
542
+		}
543
+		time.Sleep(500 * time.Millisecond)
544
+	}
545
+	return nil
546
+}
547
+
533 548
 func (container *Container) monitor() {
534 549
 	// Wait for the program to exit
535 550
 	Debugf("Waiting for process")
536
-	if err := container.cmd.Wait(); err != nil {
537
-		// Discard the error as any signals or non 0 returns will generate an error
538
-		Debugf("%s: Process: %s", container.Id, err)
551
+
552
+	// If the command does not exists, try to wait via lxc
553
+	if container.cmd == nil {
554
+		if err := container.waitLxc(); err != nil {
555
+			Debugf("%s: Process: %s", container.Id, err)
556
+		}
557
+	} else {
558
+		if err := container.cmd.Wait(); err != nil {
559
+			// Discard the error as any signals or non 0 returns will generate an error
560
+			Debugf("%s: Process: %s", container.Id, err)
561
+		}
539 562
 	}
540 563
 	Debugf("Process finished")
541 564
 
542
-	exitCode := container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
565
+	var exitCode int = -1
566
+	if container.cmd != nil {
567
+		exitCode = container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
568
+	}
543 569
 
544 570
 	// Cleanup
545 571
 	container.releaseNetwork()
... ...
@@ -588,7 +614,7 @@ func (container *Container) monitor() {
588 588
 }
589 589
 
590 590
 func (container *Container) kill() error {
591
-	if !container.State.Running || container.cmd == nil {
591
+	if !container.State.Running {
592 592
 		return nil
593 593
 	}
594 594
 
... ...
@@ -600,6 +626,9 @@ func (container *Container) kill() error {
600 600
 
601 601
 	// 2. Wait for the process to die, in last resort, try to kill the process directly
602 602
 	if err := container.WaitTimeout(10 * time.Second); err != nil {
603
+		if container.cmd == nil {
604
+			return fmt.Errorf("lxc-kill failed, impossible to kill the container %s", container.Id)
605
+		}
603 606
 		log.Printf("Container %s failed to exit within 10 seconds of lxc SIGKILL - trying direct SIGKILL", container.Id)
604 607
 		if err := container.cmd.Process.Kill(); err != nil {
605 608
 			return err
... ...
@@ -617,9 +646,6 @@ func (container *Container) Kill() error {
617 617
 	if !container.State.Running {
618 618
 		return nil
619 619
 	}
620
-	if container.State.Ghost {
621
-		return fmt.Errorf("Can't kill ghost container")
622
-	}
623 620
 	return container.kill()
624 621
 }
625 622
 
... ...
@@ -629,9 +655,6 @@ func (container *Container) Stop(seconds int) error {
629 629
 	if !container.State.Running {
630 630
 		return nil
631 631
 	}
632
-	if container.State.Ghost {
633
-		return fmt.Errorf("Can't stop ghost container")
634
-	}
635 632
 
636 633
 	// 1. Send a SIGTERM
637 634
 	if output, err := exec.Command("lxc-kill", "-n", container.Id, "15").CombinedOutput(); err != nil {
... ...
@@ -10,7 +10,7 @@ Building blocks
10 10
 
11 11
 Images
12 12
 ------
13
-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
13
+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
14 14
 
15 15
 Images are stored on your local file system under /var/lib/docker/images
16 16
 
... ...
@@ -49,7 +49,7 @@ Save the changed we just made in the container to a new image called "_/builds/g
49 49
     WEB_WORKER=$(docker run -d -p 5000 $BUILD_IMG /usr/local/bin/runapp)
50 50
 
51 51
 - **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon.
52
-  **"-p 5000"* the web app is going to listen on this port, so it must be mapped from the container to the host system.
52
+- **"-p 5000"** the web app is going to listen on this port, so it must be mapped from the container to the host system.
53 53
 - **"$BUILD_IMG"** is the image we want to run the command inside of.
54 54
 - **/usr/local/bin/runapp** is the command which starts the web app.
55 55
 
... ...
@@ -71,40 +71,38 @@
71 71
                 <h2>
72 72
                     <a name="installing-on-ubuntu-1204-and-1210" class="anchor" href="#installing-on-ubuntu-1204-and-1210"><span class="mini-icon mini-icon-link"></span>
73 73
                     </a>Installing on Ubuntu</h2>
74
-                    <strong>Requirements</strong>
74
+
75
+                    <p><strong>Requirements</strong></p>
75 76
                     <ul>
76
-                        <li>Ubuntu 12.04 (LTS) or Ubuntu 12.10</li>
77
-                        <li><strong>64-bit Operating system</strong></li>
77
+                        <li>Ubuntu 12.04 (LTS) (64-bit)</li>
78
+                        <li> or Ubuntu 12.10 (quantal) (64-bit)</li>
78 79
                     </ul>
79 80
                 <ol>
80 81
                     <li>
81
-                        <p>Add the Ubuntu PPA (Personal Package Archive) sources to your apt sources list. Copy and
82
-                            paste the following lines at once.</p>
82
+                    <p><strong>Install dependencies</strong></p>
83
+                    The linux-image-extra package is only needed on standard Ubuntu EC2 AMIs in order to install the aufs kernel module.
84
+                    <pre>sudo apt-get install linux-image-extra-`uname -r`</pre>
83 85
 
84
-                        <div class="highlight">
85
-                            <pre>sudo sh -c "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >> /etc/apt/sources.list"</pre>
86 86
 
87 87
                     </li>
88 88
                     <li>
89
-                        <p>Update your sources. You will see a warning that GPG signatures cannot be verified.</p>
90
-
89
+                        <p><strong>Install Docker</strong></p>
90
+                        <p>Add the Ubuntu PPA (Personal Package Archive) sources to your apt sources list, update and install.</p>
91
+                        <p>You may see some warnings that the GPG keys cannot be verified.</p>
91 92
                         <div class="highlight">
93
+                            <pre>sudo sh -c "echo 'deb http://ppa.launchpad.net/dotcloud/lxc-docker/ubuntu precise main' >> /etc/apt/sources.list"</pre>
92 94
                             <pre>sudo apt-get update</pre>
93
-                        </div>
94
-                    </li>
95
-                    <li>
96
-                        <p>Now install it, you will see another warning that the package cannot be authenticated. Confirm install.</p>
97
-
98
-                        <div class="highlight">
99 95
                             <pre>sudo apt-get install lxc-docker</pre>
100 96
                         </div>
97
+
98
+
101 99
                     </li>
102 100
 
103 101
                     <li>
104 102
                         <p><strong>Run!</strong></p>
105 103
 
106 104
                         <div class="highlight">
107
-                            <pre>docker</pre>
105
+                            <pre>docker run -i -t ubuntu /bin/bash</pre>
108 106
                         </div>
109 107
                     </li>
110 108
                     Continue with the <a href="http://docs.docker.io/en/latest/examples/hello_world/">Hello world</a> example.
... ...
@@ -44,6 +44,7 @@ new kernel will be compiled and this can take quite a while.
44 44
 
45 45
     yaourt -S lxc-docker-git
46 46
 
47
+
47 48
 Starting Docker
48 49
 ---------------
49 50
 
... ...
@@ -56,10 +57,7 @@ There is a systemd service unit created for docker.  To start the docker service
56 56
 
57 57
     sudo systemctl start docker
58 58
 
59
-<<<<<<< HEAD
60 59
 
61
-=======
62
->>>>>>> dotcloud/master
63 60
 To start on system boot:
64 61
 
65 62
 ::
... ...
@@ -1,56 +1,53 @@
1
-.. _ubuntu_linux:
1
+.. _binaries:
2 2
 
3
-Ubuntu Linux
4
-============
3
+Binaries
4
+========
5 5
 
6 6
   **Please note this project is currently under heavy development. It should not be used in production.**
7 7
 
8 8
 
9
-
10
-Installing on Ubuntu 12.04 and 12.10
11
-
12 9
 Right now, the officially supported distributions are:
13 10
 
14
-Ubuntu 12.04 (precise LTS)
15
-Ubuntu 12.10 (quantal)
16
-Docker probably works on other distributions featuring a recent kernel, the AUFS patch, and up-to-date lxc. However this has not been tested.
11
+- Ubuntu 12.04 (precise LTS) (64-bit)
12
+- Ubuntu 12.10 (quantal) (64-bit)
13
+
17 14
 
18 15
 Install dependencies:
19 16
 ---------------------
20 17
 
21 18
 ::
22 19
 
23
-    sudo apt-get install lxc wget bsdtar curl
20
+    sudo apt-get install lxc bsdtar
24 21
     sudo apt-get install linux-image-extra-`uname -r`
25 22
 
26 23
 The linux-image-extra package is needed on standard Ubuntu EC2 AMIs in order to install the aufs kernel module.
27 24
 
28
-Install the latest docker binary:
25
+Install the docker binary:
29 26
 
30 27
 ::
31 28
 
32
-    wget http://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-master.tgz
29
+    wget http://get.docker.io/builds/Linux/x86_64/docker-master.tgz
33 30
     tar -xf docker-master.tgz
31
+    sudo cp ./docker-master /usr/local/bin
34 32
 
35
-Run your first container!
33
+Note: docker currently only supports 64-bit Linux hosts.
36 34
 
37
-::
38 35
 
39
-    cd docker-master
36
+Run the docker daemon
37
+---------------------
40 38
 
41 39
 ::
42 40
 
43
-    sudo ./docker run -i -t base /bin/bash
41
+    sudo docker -d &
44 42
 
45 43
 
46
-To run docker as a daemon, in the background, and allow non-root users to run ``docker`` start
47
-docker -d
44
+Run your first container!
45
+-------------------------
48 46
 
49 47
 ::
50 48
 
51
-    sudo ./docker -d &
49
+    docker run -i -t ubuntu /bin/bash
52 50
 
53 51
 
54
-Consider adding docker to your PATH for simplicity.
55 52
 
56 53
 Continue with the :ref:`hello_world` example.
57 54
\ No newline at end of file
... ...
@@ -13,6 +13,7 @@ Contents:
13 13
    :maxdepth: 1
14 14
 
15 15
    ubuntulinux
16
+   binaries
16 17
    archlinux
17 18
    vagrant
18 19
    windows
19 20
deleted file mode 100644
... ...
@@ -1,66 +0,0 @@
1
-
2
-Mac OS X and other linux
3
-========================
4
-
5
-  Please note this is a community contributed installation path. The only 'official' installation is using the :ref:`ubuntu_linux` installation path. This version
6
-  may be out of date because it depends on some binaries to be updated and published
7
-
8
-
9
-Requirements
10
-
11
-We currently rely on some Ubuntu-linux specific packages, this will change in the future, but for now we provide a
12
-streamlined path to install Virtualbox with a Ubuntu 12.10 image using Vagrant.
13
-
14
-1. Install virtualbox from https://www.virtualbox.org/ (or use your package manager)
15
-2. Install vagrant from http://www.vagrantup.com/ (or use your package manager)
16
-3. Install git if you had not installed it before, check if it is installed by running
17
-   ``git`` in a terminal window
18
-
19
-We recommend having at least about 2Gb of free disk space and 2Gb RAM (or more).
20
-
21
-Installation
22
-
23
-1. Fetch the docker sources
24
-
25
-.. code-block:: bash
26
-
27
-   git clone https://github.com/dotcloud/docker.git
28
-
29
-2. Run vagrant from the sources directory
30
-
31
-.. code-block:: bash
32
-
33
-    vagrant up
34
-
35
-Vagrant will:
36
-
37
-* Download the Quantal64 base ubuntu virtual machine image from get.docker.io/
38
-* Boot this image in virtualbox
39
-
40
-Then it will use Puppet to perform an initial setup in this machine:
41
-
42
-* Download & untar the most recent docker binary tarball to vagrant homedir.
43
-* Debootstrap to /var/lib/docker/images/ubuntu.
44
-* Install & run dockerd as service.
45
-* Put docker in /usr/local/bin.
46
-* Put latest Go toolchain in /usr/local/go.
47
-
48
-You now have a Ubuntu Virtual Machine running with docker pre-installed.
49
-
50
-To access the VM and use Docker, Run ``vagrant ssh`` from the same directory as where you ran
51
-``vagrant up``. Vagrant will make sure to connect you to the correct VM.
52
-
53
-.. code-block:: bash
54
-
55
-    vagrant ssh
56
-
57
-Now you are in the VM, run docker
58
-
59
-.. code-block:: bash
60
-
61
-    docker
62
-
63
-
64
-Continue with the :ref:`hello_world` example.
... ...
@@ -6,17 +6,31 @@ Ubuntu Linux
6 6
   **Please note this project is currently under heavy development. It should not be used in production.**
7 7
 
8 8
 
9
-Docker is now available as a Ubuntu PPA (Personal Package Archive),
9
+Right now, the officially supported distributions are:
10
+
11
+- Ubuntu 12.04 (precise LTS) (64-bit)
12
+- Ubuntu 12.10 (quantal) (64-bit)
13
+
14
+Dependencies
15
+------------
16
+
17
+The linux-image-extra package is only needed on standard Ubuntu EC2 AMIs in order to install the aufs kernel module.
18
+
19
+.. code-block:: bash
20
+
21
+   sudo apt-get install linux-image-extra-`uname -r`
22
+
23
+
24
+Installation
25
+------------
26
+
27
+Docker is available as a Ubuntu PPA (Personal Package Archive),
10 28
 `hosted on launchpad  <https://launchpad.net/~dotcloud/+archive/lxc-docker>`_
11 29
 which makes installing Docker on Ubuntu very easy.
12 30
 
13
-**The Requirements**
14
-
15
-* Ubuntu 12.04 (LTS) or Ubuntu 12.10
16
-* **64-bit Operating system**
17 31
 
18 32
 
19
-Add the custom package sources to your apt sources list. Copy and paste both the following lines at once.
33
+Add the custom package sources to your apt sources list. Copy and paste the following lines at once.
20 34
 
21 35
 .. code-block:: bash
22 36
 
... ...
@@ -1,8 +1,8 @@
1 1
 
2 2
 .. _install_using_vagrant:
3 3
 
4
-Install using Vagrant
5
-=====================
4
+Using Vagrant
5
+=============
6 6
 
7 7
   Please note this is a community contributed installation path. The only 'official' installation is using the
8 8
   :ref:`ubuntu_linux` installation path. This version may sometimes be out of date.
... ...
@@ -27,37 +27,44 @@ Spin it up
27 27
 
28 28
 1. Fetch the docker sources (this includes the Vagrantfile for machine setup).
29 29
 
30
-.. code-block:: bash
30
+   .. code-block:: bash
31 31
 
32
-   git clone https://github.com/dotcloud/docker.git
32
+      git clone https://github.com/dotcloud/docker.git
33 33
 
34 34
 2. Run vagrant from the sources directory
35 35
 
36
-.. code-block:: bash
36
+   .. code-block:: bash
37
+
38
+      vagrant up
37 39
 
38
-    vagrant up
40
+   Vagrant will:
39 41
 
40
-Vagrant will:
42
+   * Download the 'official' Precise64 base ubuntu virtual machine image from vagrantup.com
43
+   * Boot this image in virtualbox
44
+   * Add the `Docker PPA sources <https://launchpad.net/~dotcloud/+archive/lxc-docker>`_ to /etc/apt/sources.lst
45
+   * Update your sources
46
+   * Install lxc-docker
41 47
 
42
-* Download the 'official' Precise64 base ubuntu virtual machine image from vagrantup.com
43
-* Boot this image in virtualbox
44
-* Add the `Docker PPA sources <https://launchpad.net/~dotcloud/+archive/lxc-docker>`_ to /etc/apt/sources.lst
45
-* Update your sources
46
-* Install lxc-docker
48
+   You now have a Ubuntu Virtual Machine running with docker pre-installed.
47 49
 
48
-You now have a Ubuntu Virtual Machine running with docker pre-installed.
50
+Connect
51
+-------
49 52
 
50 53
 To access the VM and use Docker, Run ``vagrant ssh`` from the same directory as where you ran
51 54
 ``vagrant up``. Vagrant will connect you to the correct VM.
52 55
 
53 56
 .. code-block:: bash
54 57
 
55
-    vagrant ssh
58
+   vagrant ssh
59
+
60
+Run
61
+-----
56 62
 
57 63
 Now you are in the VM, run docker
58 64
 
59 65
 .. code-block:: bash
60 66
 
61
-    docker
67
+   docker
68
+
62 69
 
63 70
 Continue with the :ref:`hello_world` example.
64 71
new file mode 100644
... ...
@@ -0,0 +1,11 @@
0
+# This will build a container capable of producing an official binary build of docker and
1
+# uploading it to S3
2
+from	ubuntu:12.10
3
+run	apt-get update
4
+run	RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q s3cmd
5
+run	RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q golang
6
+run	RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q git
7
+run	RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive apt-get install -y -q build-essential
8
+copy	dockerbuilder	/usr/local/bin/dockerbuilder
9
+copy	s3cfg	/.s3cfg
10
+# run $img dockerbuilder $REVISION_OR_TAG $S3_ID $S3_KEY
0 11
new file mode 100644
... ...
@@ -0,0 +1,29 @@
0
+#!/bin/sh
1
+set -x
2
+set -e
3
+
4
+PACKAGE=github.com/dotcloud/docker
5
+
6
+if [ $# -lt 3 ]; then
7
+	echo "Usage: $0 REVISION AWS_ID AWS_KEY"
8
+	exit 1
9
+fi
10
+
11
+export REVISION=$1 AWS_ID=$2 AWS_KEY=$3
12
+
13
+
14
+export PATH=/usr/local/bin:$PATH
15
+
16
+mkdir -p /go/src/$PACKAGE
17
+git clone "https://$PACKAGE" /go/src/$PACKAGE
18
+cd /go/src/$PACKAGE
19
+git checkout $REVISION
20
+
21
+# FIXME: checkout to specific revision
22
+
23
+BUILDDIR=/tmp/docker-$REVISION
24
+mkdir -p $BUILDDIR
25
+(cd docker && go get && go build -o $BUILDDIR/docker)
26
+
27
+tar -f /tmp/docker.tgz -C $(dirname $BUILDDIR) -zc $(basename $BUILDDIR)
28
+s3cmd -P put /tmp/docker.tgz s3://get.docker.io/builds/$(uname -s)/$(uname -m)/docker-$REVISION.tgz
0 29
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+[default]
1
+access_key = $AWS_ID
2
+secret_key = $AWS_KEY
... ...
@@ -184,12 +184,6 @@ func (runtime *Runtime) Register(container *Container) error {
184 184
 		}
185 185
 	}
186 186
 
187
-	// If the container is not running or just has been flagged not running
188
-	// then close the wait lock chan (will be reset upon start)
189
-	if !container.State.Running {
190
-		close(container.waitLock)
191
-	}
192
-
193 187
 	// Even if not running, we init the lock (prevents races in start/stop/kill)
194 188
 	container.State.initLock()
195 189
 
... ...
@@ -207,6 +201,15 @@ func (runtime *Runtime) Register(container *Container) error {
207 207
 	// done
208 208
 	runtime.containers.PushBack(container)
209 209
 	runtime.idIndex.Add(container.Id)
210
+
211
+	// If the container is not running or just has been flagged not running
212
+	// then close the wait lock chan (will be reset upon start)
213
+	if !container.State.Running {
214
+		close(container.waitLock)
215
+	} else {
216
+		container.allocateNetwork()
217
+		go container.monitor()
218
+	}
210 219
 	return nil
211 220
 }
212 221
 
... ...
@@ -273,7 +273,7 @@ func TestAllocatePortLocalhost(t *testing.T) {
273 273
 		t.Fatal(err)
274 274
 	}
275 275
 	defer container.Kill()
276
-	time.Sleep(300 * time.Millisecond) // Wait for the container to run
276
+	time.Sleep(600 * time.Millisecond) // Wait for the container to run
277 277
 	conn, err := net.Dial("tcp",
278 278
 		fmt.Sprintf(
279 279
 			"localhost:%s", container.NetworkSettings.PortMapping["5555"],
... ...
@@ -442,7 +442,7 @@ func FindCgroupMountpoint(cgroupType string) (string, error) {
442 442
 		return "", err
443 443
 	}
444 444
 
445
-	reg := regexp.MustCompile(`^cgroup on (.*) type cgroup \(.*` + cgroupType + `[,\)]`)
445
+	reg := regexp.MustCompile(`^.* on (.*) type cgroup \(.*` + cgroupType + `[,\)]`)
446 446
 	for _, line := range strings.Split(string(output), "\n") {
447 447
 		r := reg.FindStringSubmatch(line)
448 448
 		if len(r) == 2 {