Browse code

Merge branch 'master' of ssh://github.com/dotcloud/docker

Solomon Hykes authored on 2013/06/15 07:07:05
Showing 3 changed files
... ...
@@ -5,11 +5,13 @@ BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
5 5
 BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
6 6
 AWS_REGION = ENV['AWS_REGION'] || "us-east-1"
7 7
 AWS_AMI    = ENV['AWS_AMI']    || "ami-d0f89fb9"
8
+FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS']
8 9
 
9 10
 Vagrant::Config.run do |config|
10 11
   # Setup virtual machine box. This VM configuration code is always executed.
11 12
   config.vm.box = BOX_NAME
12 13
   config.vm.box_url = BOX_URI
14
+  config.vm.forward_port 4243, 4243
13 15
 
14 16
   # Provision docker and new kernel if deployment was not done
15 17
   if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").empty?
... ...
@@ -70,3 +72,17 @@ Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
70 70
     config.vm.box_url = BOX_URI
71 71
   end
72 72
 end
73
+
74
+if !FORWARD_DOCKER_PORTS.nil?
75
+    Vagrant::VERSION < "1.1.0" and Vagrant::Config.run do |config|
76
+        (49000..49900).each do |port|
77
+            config.vm.forward_port port, port
78
+        end
79
+    end
80
+
81
+    Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
82
+        (49000..49900).each do |port|
83
+            config.vm.network :forwarded_port, :host => port, :guest => port
84
+        end
85
+    end
86
+end
... ...
@@ -658,6 +658,10 @@ func (srv *Server) ImageImport(src, repo, tag string, in io.Reader, out io.Write
658 658
 
659 659
 func (srv *Server) ContainerCreate(config *Config) (string, error) {
660 660
 
661
+	if config.Memory != 0 && config.Memory < 524288 {
662
+		return "", fmt.Errorf("Memory limit must be given in bytes (minimum 524288 bytes)")
663
+	}
664
+
661 665
 	if config.Memory > 0 && !srv.runtime.capabilities.MemoryLimit {
662 666
 		config.Memory = 0
663 667
 	}
... ...
@@ -147,3 +147,25 @@ func TestCreateStartRestartStopStartKillRm(t *testing.T) {
147 147
 	}
148 148
 
149 149
 }
150
+
151
+func TestRunWithTooLowMemoryLimit(t *testing.T) {
152
+	runtime, err := newTestRuntime()
153
+	srv := &Server{runtime: runtime}
154
+	if err != nil {
155
+		t.Fatal(err)
156
+	}
157
+	defer nuke(runtime)
158
+	// Try to create a container with a memory limit of 1 byte less than the minimum allowed limit.
159
+	_, err = srv.ContainerCreate(
160
+		&Config{
161
+			Image:     GetTestImage(runtime).ID,
162
+			Memory:    524287,
163
+			CpuShares: 1000,
164
+			Cmd:       []string{"/bin/cat"},
165
+		},
166
+	)
167
+	if err == nil {
168
+		t.Errorf("Memory limit is smaller than the allowed limit. Container creation should've failed!")
169
+	}
170
+
171
+}