Browse code

Remove PortSpecs from Config

Signed-off-by: Antonio Murdaca <me@runcom.ninja>

Antonio Murdaca authored on 2015/05/24 22:17:29
Showing 20 changed files
... ...
@@ -453,19 +453,11 @@ func expose(b *Builder, args []string, attributes map[string]bool, original stri
453 453
 		b.Config.ExposedPorts = make(nat.PortSet)
454 454
 	}
455 455
 
456
-	ports, bindingMap, err := nat.ParsePortSpecs(append(portsTab, b.Config.PortSpecs...))
456
+	ports, _, err := nat.ParsePortSpecs(portsTab)
457 457
 	if err != nil {
458 458
 		return err
459 459
 	}
460 460
 
461
-	for _, bindings := range bindingMap {
462
-		if bindings[0].HostIp != "" || bindings[0].HostPort != "" {
463
-			fmt.Fprintf(b.ErrStream, " ---> Using Dockerfile's EXPOSE instruction"+
464
-				"      to map host ports to container ports (ip:hostPort:containerPort) is deprecated.\n"+
465
-				"      Please use -p to publish the ports.\n")
466
-		}
467
-	}
468
-
469 461
 	// instead of using ports directly, we build a list of ports and sort it so
470 462
 	// the order is consistent. This prevents cache burst where map ordering
471 463
 	// changes between builds
... ...
@@ -479,7 +471,6 @@ func expose(b *Builder, args []string, attributes map[string]bool, original stri
479 479
 		i++
480 480
 	}
481 481
 	sort.Strings(portList)
482
-	b.Config.PortSpecs = nil
483 482
 	return b.commit("", b.Config.Cmd, fmt.Sprintf("EXPOSE %s", strings.Join(portList, " ")))
484 483
 }
485 484
 
... ...
@@ -642,16 +642,6 @@ func (container *Container) buildCreateEndpointOptions() ([]libnetwork.EndpointO
642 642
 		createOptions []libnetwork.EndpointOption
643 643
 	)
644 644
 
645
-	if container.Config.PortSpecs != nil {
646
-		if err := migratePortMappings(container.Config, container.hostConfig); err != nil {
647
-			return nil, err
648
-		}
649
-		container.Config.PortSpecs = nil
650
-		if err := container.WriteHostConfig(); err != nil {
651
-			return nil, err
652
-		}
653
-	}
654
-
655 645
 	if container.Config.ExposedPorts != nil {
656 646
 		portSpecs = container.Config.ExposedPorts
657 647
 	}
... ...
@@ -66,7 +66,7 @@ func (daemon *Daemon) Create(config *runconfig.Config, hostConfig *runconfig.Hos
66 66
 		imgID = img.ID
67 67
 	}
68 68
 
69
-	if warnings, err = daemon.mergeAndVerifyConfig(config, img); err != nil {
69
+	if err := daemon.mergeAndVerifyConfig(config, img); err != nil {
70 70
 		return nil, nil, err
71 71
 	}
72 72
 	if !config.NetworkDisabled && daemon.SystemConfig().IPv4ForwardingDisabled {
... ...
@@ -355,33 +355,16 @@ func (daemon *Daemon) restore() error {
355 355
 	return nil
356 356
 }
357 357
 
358
-func (daemon *Daemon) checkDeprecatedExpose(config *runconfig.Config) bool {
359
-	if config != nil {
360
-		if config.PortSpecs != nil {
361
-			for _, p := range config.PortSpecs {
362
-				if strings.Contains(p, ":") {
363
-					return true
364
-				}
365
-			}
366
-		}
367
-	}
368
-	return false
369
-}
370
-
371
-func (daemon *Daemon) mergeAndVerifyConfig(config *runconfig.Config, img *image.Image) ([]string, error) {
372
-	warnings := []string{}
373
-	if (img != nil && daemon.checkDeprecatedExpose(img.Config)) || daemon.checkDeprecatedExpose(config) {
374
-		warnings = append(warnings, "The mapping to public ports on your host via Dockerfile EXPOSE (host:port:port) has been deprecated. Use -p to publish the ports.")
375
-	}
358
+func (daemon *Daemon) mergeAndVerifyConfig(config *runconfig.Config, img *image.Image) error {
376 359
 	if img != nil && img.Config != nil {
377 360
 		if err := runconfig.Merge(config, img.Config); err != nil {
378
-			return nil, err
361
+			return err
379 362
 		}
380 363
 	}
381 364
 	if config.Entrypoint.Len() == 0 && config.Cmd.Len() == 0 {
382
-		return nil, fmt.Errorf("No command specified")
365
+		return fmt.Errorf("No command specified")
383 366
 	}
384
-	return warnings, nil
367
+	return nil
385 368
 }
386 369
 
387 370
 func (daemon *Daemon) generateIdAndName(name string) (string, string, error) {
... ...
@@ -5,34 +5,9 @@ import (
5 5
 	"fmt"
6 6
 	"strings"
7 7
 
8
-	"github.com/docker/docker/nat"
9 8
 	"github.com/docker/docker/runconfig"
10 9
 )
11 10
 
12
-func migratePortMappings(config *runconfig.Config, hostConfig *runconfig.HostConfig) error {
13
-	if config.PortSpecs != nil {
14
-		ports, bindings, err := nat.ParsePortSpecs(config.PortSpecs)
15
-		if err != nil {
16
-			return err
17
-		}
18
-		config.PortSpecs = nil
19
-		if len(bindings) > 0 {
20
-			if hostConfig == nil {
21
-				hostConfig = &runconfig.HostConfig{}
22
-			}
23
-			hostConfig.PortBindings = bindings
24
-		}
25
-
26
-		if config.ExposedPorts == nil {
27
-			config.ExposedPorts = make(nat.PortSet, len(ports))
28
-		}
29
-		for k, v := range ports {
30
-			config.ExposedPorts[k] = v
31
-		}
32
-	}
33
-	return nil
34
-}
35
-
36 11
 func mergeLxcConfIntoOptions(hostConfig *runconfig.HostConfig) ([]string, error) {
37 12
 	if hostConfig == nil {
38 13
 		return nil, nil
... ...
@@ -61,7 +61,6 @@ To get information on a container use its ID or instance name:
61 61
             "NetworkDisabled": false,
62 62
             "OnBuild": null,
63 63
             "OpenStdin": false,
64
-            "PortSpecs": null,
65 64
             "StdinOnce": false,
66 65
             "Tty": true,
67 66
             "User": "",
... ...
@@ -215,7 +214,6 @@ on it.
215 215
             "NetworkDisabled": false,
216 216
             "OnBuild": [],
217 217
             "OpenStdin": false,
218
-            "PortSpecs": null,
219 218
             "StdinOnce": false,
220 219
             "Tty": false,
221 220
             "User": "",
... ...
@@ -247,7 +245,6 @@ on it.
247 247
             "NetworkDisabled": false,
248 248
             "OnBuild": [],
249 249
             "OpenStdin": false,
250
-            "PortSpecs": null,
251 250
             "StdinOnce": false,
252 251
             "Tty": false,
253 252
             "User": "",
... ...
@@ -333,7 +333,6 @@ Return low-level information on the container `id`
333 333
 			"NetworkDisabled": false,
334 334
 			"OnBuild": null,
335 335
 			"OpenStdin": false,
336
-			"PortSpecs": null,
337 336
 			"StdinOnce": false,
338 337
 			"Tty": false,
339 338
 			"User": "",
... ...
@@ -1346,7 +1345,6 @@ Return low-level information on the image `name`
1346 1346
                          "AttachStdin": false,
1347 1347
                          "AttachStdout": false,
1348 1348
                          "AttachStderr": false,
1349
-                         "PortSpecs": null,
1350 1349
                          "Tty": true,
1351 1350
                          "OpenStdin": true,
1352 1351
                          "StdinOnce": false,
... ...
@@ -1741,7 +1739,6 @@ Create a new image from a container's changes
1741 1741
          "AttachStdin": false,
1742 1742
          "AttachStdout": true,
1743 1743
          "AttachStderr": true,
1744
-         "PortSpecs": null,
1745 1744
          "Tty": false,
1746 1745
          "OpenStdin": false,
1747 1746
          "StdinOnce": false,
... ...
@@ -2095,7 +2092,6 @@ Return low-level information about the `exec` command `id`.
2095 2095
           "AttachStdin" : false,
2096 2096
           "AttachStdout" : false,
2097 2097
           "AttachStderr" : false,
2098
-          "PortSpecs" : null,
2099 2098
           "ExposedPorts" : null,
2100 2099
           "Tty" : false,
2101 2100
           "OpenStdin" : false,
... ...
@@ -176,7 +176,6 @@ Put image for a given `image_id`
176 176
                 AttachStdin: false,
177 177
                 AttachStdout: false,
178 178
                 AttachStderr: false,
179
-                PortSpecs: null,
180 179
                 Tty: false,
181 180
                 OpenStdin: false,
182 181
                 StdinOnce: false,
... ...
@@ -252,7 +251,6 @@ Parameters:
252 252
                 AttachStdin: false,
253 253
                 AttachStdout: false,
254 254
                 AttachStderr: false,
255
-                PortSpecs: null,
256 255
                 Tty: false,
257 256
                 OpenStdin: false,
258 257
                 StdinOnce: false,
... ...
@@ -842,7 +842,6 @@ func (s *DockerSuite) TestContainerApiPostCreateNull(c *check.C) {
842 842
 		"AttachStdin":true,
843 843
 		"AttachStdout":true,
844 844
 		"AttachStderr":true,
845
-		"PortSpecs":null,
846 845
 		"ExposedPorts":{},
847 846
 		"Tty":true,
848 847
 		"OpenStdin":true,
... ...
@@ -2406,31 +2406,6 @@ func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *check.C) {
2406 2406
 	}
2407 2407
 }
2408 2408
 
2409
-func (s *DockerSuite) TestBuildExposeHostPort(c *check.C) {
2410
-	// start building docker file with ip:hostPort:containerPort
2411
-	name := "testbuildexpose"
2412
-	expected := "map[5678/tcp:{}]"
2413
-	_, out, err := buildImageWithOut(name,
2414
-		`FROM scratch
2415
-        EXPOSE 192.168.1.2:2375:5678`,
2416
-		true)
2417
-	if err != nil {
2418
-		c.Fatal(err)
2419
-	}
2420
-
2421
-	if !strings.Contains(out, "to map host ports to container ports (ip:hostPort:containerPort) is deprecated.") {
2422
-		c.Fatal("Missing warning message")
2423
-	}
2424
-
2425
-	res, err := inspectField(name, "Config.ExposedPorts")
2426
-	if err != nil {
2427
-		c.Fatal(err)
2428
-	}
2429
-	if res != expected {
2430
-		c.Fatalf("Exposed ports %s, expected %s", res, expected)
2431
-	}
2432
-}
2433
-
2434 2409
 func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) {
2435 2410
 	name := "testbuildentrypointinheritance"
2436 2411
 	name2 := "testbuildentrypointinheritance2"
... ...
@@ -32,33 +32,33 @@ var testLayers = []testLayer{
32 32
 		filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
33 33
 		jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
34 34
 		version:  Version0,
35
-		tarsum:   "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"},
35
+		tarsum:   "tarsum+sha256:4095cc12fa5fdb1ab2760377e1cd0c4ecdd3e61b4f9b82319d96fcea6c9a41c6"},
36 36
 	{
37 37
 		filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
38 38
 		jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
39 39
 		version:  VersionDev,
40
-		tarsum:   "tarsum.dev+sha256:486b86e25c4db4551228154848bc4663b15dd95784b1588980f4ba1cb42e83e9"},
40
+		tarsum:   "tarsum.dev+sha256:db56e35eec6ce65ba1588c20ba6b1ea23743b59e81fb6b7f358ccbde5580345c"},
41 41
 	{
42 42
 		filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
43 43
 		jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
44 44
 		gzip:     true,
45
-		tarsum:   "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"},
45
+		tarsum:   "tarsum+sha256:4095cc12fa5fdb1ab2760377e1cd0c4ecdd3e61b4f9b82319d96fcea6c9a41c6"},
46 46
 	{
47 47
 		// Tests existing version of TarSum when xattrs are present
48 48
 		filename: "testdata/xattr/layer.tar",
49 49
 		jsonfile: "testdata/xattr/json",
50 50
 		version:  Version0,
51
-		tarsum:   "tarsum+sha256:e86f81a4d552f13039b1396ed03ca968ea9717581f9577ef1876ea6ff9b38c98"},
51
+		tarsum:   "tarsum+sha256:07e304a8dbcb215b37649fde1a699f8aeea47e60815707f1cdf4d55d25ff6ab4"},
52 52
 	{
53 53
 		// Tests next version of TarSum when xattrs are present
54 54
 		filename: "testdata/xattr/layer.tar",
55 55
 		jsonfile: "testdata/xattr/json",
56 56
 		version:  VersionDev,
57
-		tarsum:   "tarsum.dev+sha256:6235cd3a2afb7501bac541772a3d61a3634e95bc90bb39a4676e2cb98d08390d"},
57
+		tarsum:   "tarsum.dev+sha256:6c58917892d77b3b357b0f9ad1e28e1f4ae4de3a8006bd3beb8beda214d8fd16"},
58 58
 	{
59 59
 		filename: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar",
60 60
 		jsonfile: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json",
61
-		tarsum:   "tarsum+sha256:ac672ee85da9ab7f9667ae3c32841d3e42f33cc52c273c23341dabba1c8b0c8b"},
61
+		tarsum:   "tarsum+sha256:c66bd5ec9f87b8f4c6135ca37684618f486a3dd1d113b138d0a177bfa39c2571"},
62 62
 	{
63 63
 		options: &sizedOptions{1, 1024 * 1024, false, false}, // a 1mb file (in memory)
64 64
 		tarsum:  "tarsum+sha256:8bf12d7e67c51ee2e8306cba569398b1b9f419969521a12ffb9d8875e8836738"},
... ...
@@ -1 +1 @@
1
-{"id":"46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457","parent":"def3f9165934325dfd027c86530b2ea49bb57a0963eb1336b3a0415ff6fd56de","created":"2014-04-07T02:45:52.610504484Z","container":"e0f07f8d72cae171a3dcc35859960e7e956e0628bce6fedc4122bf55b2c287c7","container_config":{"Hostname":"88807319f25e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","sed -ri 's/^(%wheel.*)(ALL)$/\\1NOPASSWD: \\2/' /etc/sudoers"],"Image":"def3f9165934325dfd027c86530b2ea49bb57a0963eb1336b3a0415ff6fd56de","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"docker_version":"0.9.1-dev","config":{"Hostname":"88807319f25e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":null,"Image":"def3f9165934325dfd027c86530b2ea49bb57a0963eb1336b3a0415ff6fd56de","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"architecture":"amd64","os":"linux","Size":3425}
2 1
\ No newline at end of file
2
+{"id":"46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457","parent":"def3f9165934325dfd027c86530b2ea49bb57a0963eb1336b3a0415ff6fd56de","created":"2014-04-07T02:45:52.610504484Z","container":"e0f07f8d72cae171a3dcc35859960e7e956e0628bce6fedc4122bf55b2c287c7","container_config":{"Hostname":"88807319f25e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","sed -ri 's/^(%wheel.*)(ALL)$/\\1NOPASSWD: \\2/' /etc/sudoers"],"Image":"def3f9165934325dfd027c86530b2ea49bb57a0963eb1336b3a0415ff6fd56de","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"docker_version":"0.9.1-dev","config":{"Hostname":"88807319f25e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":null,"Image":"def3f9165934325dfd027c86530b2ea49bb57a0963eb1336b3a0415ff6fd56de","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"architecture":"amd64","os":"linux","Size":3425}
3 3
\ No newline at end of file
... ...
@@ -1 +1 @@
1
-{"id":"511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158","comment":"Imported from -","created":"2013-06-13T14:03:50.821769-07:00","container_config":{"Hostname":"","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":null,"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":null},"docker_version":"0.4.0","architecture":"x86_64","Size":0}
2 1
\ No newline at end of file
2
+{"id":"511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158","comment":"Imported from -","created":"2013-06-13T14:03:50.821769-07:00","container_config":{"Hostname":"","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":null,"Cmd":null,"Image":"","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":null},"docker_version":"0.4.0","architecture":"x86_64","Size":0}
3 3
\ No newline at end of file
... ...
@@ -1 +1 @@
1
-{"id":"4439c3c7f847954100b42b267e7e5529cac1d6934db082f65795c5ca2e594d93","parent":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","created":"2014-05-16T17:19:44.091534414Z","container":"5f92fb06cc58f357f0cde41394e2bbbb664e663974b2ac1693ab07b7a306749b","container_config":{"Hostname":"9565c6517a0e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"Cpuset":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","setcap 'cap_setgid,cap_setuid+ep' ./file \u0026\u0026 getcap ./file"],"Image":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"docker_version":"0.11.1-dev","config":{"Hostname":"9565c6517a0e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"Cpuset":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":null,"Image":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"architecture":"amd64","os":"linux","Size":0}
2 1
\ No newline at end of file
2
+{"id":"4439c3c7f847954100b42b267e7e5529cac1d6934db082f65795c5ca2e594d93","parent":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","created":"2014-05-16T17:19:44.091534414Z","container":"5f92fb06cc58f357f0cde41394e2bbbb664e663974b2ac1693ab07b7a306749b","container_config":{"Hostname":"9565c6517a0e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"Cpuset":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","setcap 'cap_setgid,cap_setuid+ep' ./file \u0026\u0026 getcap ./file"],"Image":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"docker_version":"0.11.1-dev","config":{"Hostname":"9565c6517a0e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"Cpuset":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":null,"Image":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"architecture":"amd64","os":"linux","Size":0}
3 3
\ No newline at end of file
... ...
@@ -30,7 +30,7 @@ var (
30 30
 				"comment":"test base image","created":"2013-03-23T12:53:11.10432-07:00",
31 31
 				"container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0,
32 32
 				"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,
33
-				"PortSpecs":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,
33
+				"Tty":false,"OpenStdin":false,"StdinOnce":false,
34 34
 				"Env":null,"Cmd":null,"Dns":null,"Image":"","Volumes":null,
35 35
 				"VolumesFrom":"","Entrypoint":null},"Size":424242}`,
36 36
 			"checksum_simple": "sha256:1ac330d56e05eef6d438586545ceff7550d3bdcb6b19961f12c5ba714ee1bb37",
... ...
@@ -56,7 +56,7 @@ var (
56 56
 				"comment":"test base image","created":"2013-03-23T12:55:11.10432-07:00",
57 57
 				"container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0,
58 58
 				"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,
59
-				"PortSpecs":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,
59
+				"Tty":false,"OpenStdin":false,"StdinOnce":false,
60 60
 				"Env":null,"Cmd":null,"Dns":null,"Image":"","Volumes":null,
61 61
 				"VolumesFrom":"","Entrypoint":null},"Size":424242}`,
62 62
 			"checksum_simple": "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2",
... ...
@@ -18,7 +18,6 @@ func Compare(a, b *Config) bool {
18 18
 	if a.Cmd.Len() != b.Cmd.Len() ||
19 19
 		len(a.Env) != len(b.Env) ||
20 20
 		len(a.Labels) != len(b.Labels) ||
21
-		len(a.PortSpecs) != len(b.PortSpecs) ||
22 21
 		len(a.ExposedPorts) != len(b.ExposedPorts) ||
23 22
 		a.Entrypoint.Len() != b.Entrypoint.Len() ||
24 23
 		len(a.Volumes) != len(b.Volumes) {
... ...
@@ -42,11 +41,6 @@ func Compare(a, b *Config) bool {
42 42
 			return false
43 43
 		}
44 44
 	}
45
-	for i := 0; i < len(a.PortSpecs); i++ {
46
-		if a.PortSpecs[i] != b.PortSpecs[i] {
47
-			return false
48
-		}
49
-	}
50 45
 	for k := range a.ExposedPorts {
51 46
 		if _, exists := b.ExposedPorts[k]; !exists {
52 47
 			return false
... ...
@@ -113,7 +113,6 @@ type Config struct {
113 113
 	AttachStdin     bool
114 114
 	AttachStdout    bool
115 115
 	AttachStderr    bool
116
-	PortSpecs       []string // Deprecated - Can be in the format of 8080/tcp
117 116
 	ExposedPorts    map[nat.Port]struct{}
118 117
 	Tty             bool // Attach standard streams to a tty, including stdin if it is not closed.
119 118
 	OpenStdin       bool // Open stdin
... ...
@@ -167,25 +167,30 @@ func TestParseRunVolumes(t *testing.T) {
167 167
 func TestCompare(t *testing.T) {
168 168
 	volumes1 := make(map[string]struct{})
169 169
 	volumes1["/test1"] = struct{}{}
170
+	ports1 := make(nat.PortSet)
171
+	ports1[nat.Port("1111/tcp")] = struct{}{}
172
+	ports1[nat.Port("2222/tcp")] = struct{}{}
170 173
 	config1 := Config{
171
-		PortSpecs: []string{"1111:1111", "2222:2222"},
172
-		Env:       []string{"VAR1=1", "VAR2=2"},
173
-		Volumes:   volumes1,
174
+		ExposedPorts: ports1,
175
+		Env:          []string{"VAR1=1", "VAR2=2"},
176
+		Volumes:      volumes1,
174 177
 	}
178
+	ports3 := make(nat.PortSet)
179
+	ports3[nat.Port("0000/tcp")] = struct{}{}
180
+	ports3[nat.Port("2222/tcp")] = struct{}{}
175 181
 	config3 := Config{
176
-		PortSpecs: []string{"0000:0000", "2222:2222"},
177
-		Env:       []string{"VAR1=1", "VAR2=2"},
178
-		Volumes:   volumes1,
182
+		ExposedPorts: ports3,
183
+		Volumes:      volumes1,
179 184
 	}
180 185
 	volumes2 := make(map[string]struct{})
181 186
 	volumes2["/test2"] = struct{}{}
182 187
 	config5 := Config{
183
-		PortSpecs: []string{"0000:0000", "2222:2222"},
184
-		Env:       []string{"VAR1=1", "VAR2=2"},
185
-		Volumes:   volumes2,
188
+		Env:     []string{"VAR1=1", "VAR2=2"},
189
+		Volumes: volumes2,
186 190
 	}
191
+
187 192
 	if Compare(&config1, &config3) {
188
-		t.Fatalf("Compare should return false, PortSpecs are different")
193
+		t.Fatalf("Compare should return false, ExposedPorts are different")
189 194
 	}
190 195
 	if Compare(&config1, &config5) {
191 196
 		t.Fatalf("Compare should return false, Volumes are different")
... ...
@@ -199,18 +204,24 @@ func TestMerge(t *testing.T) {
199 199
 	volumesImage := make(map[string]struct{})
200 200
 	volumesImage["/test1"] = struct{}{}
201 201
 	volumesImage["/test2"] = struct{}{}
202
+	portsImage := make(nat.PortSet)
203
+	portsImage[nat.Port("1111/tcp")] = struct{}{}
204
+	portsImage[nat.Port("2222/tcp")] = struct{}{}
202 205
 	configImage := &Config{
203
-		PortSpecs: []string{"1111:1111", "2222:2222"},
204
-		Env:       []string{"VAR1=1", "VAR2=2"},
205
-		Volumes:   volumesImage,
206
+		ExposedPorts: portsImage,
207
+		Env:          []string{"VAR1=1", "VAR2=2"},
208
+		Volumes:      volumesImage,
206 209
 	}
207 210
 
211
+	portsUser := make(nat.PortSet)
212
+	portsUser[nat.Port("2222/tcp")] = struct{}{}
213
+	portsUser[nat.Port("3333/tcp")] = struct{}{}
208 214
 	volumesUser := make(map[string]struct{})
209 215
 	volumesUser["/test3"] = struct{}{}
210 216
 	configUser := &Config{
211
-		PortSpecs: []string{"3333:2222", "3333:3333"},
212
-		Env:       []string{"VAR2=3", "VAR3=3"},
213
-		Volumes:   volumesUser,
217
+		ExposedPorts: portsUser,
218
+		Env:          []string{"VAR2=3", "VAR3=3"},
219
+		Volumes:      volumesUser,
214 220
 	}
215 221
 
216 222
 	if err := Merge(configUser, configImage); err != nil {
... ...
@@ -3,7 +3,6 @@ package runconfig
3 3
 import (
4 4
 	"strings"
5 5
 
6
-	"github.com/Sirupsen/logrus"
7 6
 	"github.com/docker/docker/nat"
8 7
 )
9 8
 
... ...
@@ -24,39 +23,6 @@ func Merge(userConf, imageConf *Config) error {
24 24
 		}
25 25
 	}
26 26
 
27
-	if len(userConf.PortSpecs) > 0 {
28
-		if userConf.ExposedPorts == nil {
29
-			userConf.ExposedPorts = make(nat.PortSet)
30
-		}
31
-		ports, _, err := nat.ParsePortSpecs(userConf.PortSpecs)
32
-		if err != nil {
33
-			return err
34
-		}
35
-		for port := range ports {
36
-			if _, exists := userConf.ExposedPorts[port]; !exists {
37
-				userConf.ExposedPorts[port] = struct{}{}
38
-			}
39
-		}
40
-		userConf.PortSpecs = nil
41
-	}
42
-	if len(imageConf.PortSpecs) > 0 {
43
-		// FIXME: I think we can safely remove this. Leaving it for now for the sake of reverse-compat paranoia.
44
-		logrus.Debugf("Migrating image port specs to container: %s", strings.Join(imageConf.PortSpecs, ", "))
45
-		if userConf.ExposedPorts == nil {
46
-			userConf.ExposedPorts = make(nat.PortSet)
47
-		}
48
-
49
-		ports, _, err := nat.ParsePortSpecs(imageConf.PortSpecs)
50
-		if err != nil {
51
-			return err
52
-		}
53
-		for port := range ports {
54
-			if _, exists := userConf.ExposedPorts[port]; !exists {
55
-				userConf.ExposedPorts[port] = struct{}{}
56
-			}
57
-		}
58
-	}
59
-
60 27
 	if len(userConf.Env) == 0 {
61 28
 		userConf.Env = imageConf.Env
62 29
 	} else {
... ...
@@ -302,7 +302,6 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
302 302
 	config := &Config{
303 303
 		Hostname:        hostname,
304 304
 		Domainname:      domainname,
305
-		PortSpecs:       nil, // Deprecated
306 305
 		ExposedPorts:    ports,
307 306
 		User:            *flUser,
308 307
 		Tty:             *flTty,