diff --git a/builder/dispatchers.go b/builder/dispatchers.go index 6d0a30c0c3..3c362f4c19 100644 --- a/builder/dispatchers.go +++ b/builder/dispatchers.go @@ -453,19 +453,11 @@ func expose(b *Builder, args []string, attributes map[string]bool, original stri b.Config.ExposedPorts = make(nat.PortSet) } - ports, bindingMap, err := nat.ParsePortSpecs(append(portsTab, b.Config.PortSpecs...)) + ports, _, err := nat.ParsePortSpecs(portsTab) if err != nil { return err } - for _, bindings := range bindingMap { - if bindings[0].HostIp != "" || bindings[0].HostPort != "" { - fmt.Fprintf(b.ErrStream, " ---> Using Dockerfile's EXPOSE instruction"+ - " to map host ports to container ports (ip:hostPort:containerPort) is deprecated.\n"+ - " Please use -p to publish the ports.\n") - } - } - // instead of using ports directly, we build a list of ports and sort it so // the order is consistent. This prevents cache burst where map ordering // changes between builds @@ -479,7 +471,6 @@ func expose(b *Builder, args []string, attributes map[string]bool, original stri i++ } sort.Strings(portList) - b.Config.PortSpecs = nil return b.commit("", b.Config.Cmd, fmt.Sprintf("EXPOSE %s", strings.Join(portList, " "))) } diff --git a/daemon/container_linux.go b/daemon/container_linux.go index 8dd839eb6f..9ee94da9f2 100644 --- a/daemon/container_linux.go +++ b/daemon/container_linux.go @@ -642,16 +642,6 @@ func (container *Container) buildCreateEndpointOptions() ([]libnetwork.EndpointO createOptions []libnetwork.EndpointOption ) - if container.Config.PortSpecs != nil { - if err := migratePortMappings(container.Config, container.hostConfig); err != nil { - return nil, err - } - container.Config.PortSpecs = nil - if err := container.WriteHostConfig(); err != nil { - return nil, err - } - } - if container.Config.ExposedPorts != nil { portSpecs = container.Config.ExposedPorts } diff --git a/daemon/create.go b/daemon/create.go index 2f78d7c197..51eff898eb 100644 --- a/daemon/create.go +++ b/daemon/create.go @@ -66,7 +66,7 @@ func (daemon *Daemon) Create(config *runconfig.Config, hostConfig *runconfig.Hos imgID = img.ID } - if warnings, err = daemon.mergeAndVerifyConfig(config, img); err != nil { + if err := daemon.mergeAndVerifyConfig(config, img); err != nil { return nil, nil, err } if !config.NetworkDisabled && daemon.SystemConfig().IPv4ForwardingDisabled { diff --git a/daemon/daemon.go b/daemon/daemon.go index 34ebb91ae8..47fb3e5584 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -355,33 +355,16 @@ func (daemon *Daemon) restore() error { return nil } -func (daemon *Daemon) checkDeprecatedExpose(config *runconfig.Config) bool { - if config != nil { - if config.PortSpecs != nil { - for _, p := range config.PortSpecs { - if strings.Contains(p, ":") { - return true - } - } - } - } - return false -} - -func (daemon *Daemon) mergeAndVerifyConfig(config *runconfig.Config, img *image.Image) ([]string, error) { - warnings := []string{} - if (img != nil && daemon.checkDeprecatedExpose(img.Config)) || daemon.checkDeprecatedExpose(config) { - 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.") - } +func (daemon *Daemon) mergeAndVerifyConfig(config *runconfig.Config, img *image.Image) error { if img != nil && img.Config != nil { if err := runconfig.Merge(config, img.Config); err != nil { - return nil, err + return err } } if config.Entrypoint.Len() == 0 && config.Cmd.Len() == 0 { - return nil, fmt.Errorf("No command specified") + return fmt.Errorf("No command specified") } - return warnings, nil + return nil } func (daemon *Daemon) generateIdAndName(name string) (string, string, error) { diff --git a/daemon/utils.go b/daemon/utils.go index ec001ca071..1dbffb6812 100644 --- a/daemon/utils.go +++ b/daemon/utils.go @@ -5,34 +5,9 @@ import ( "fmt" "strings" - "github.com/docker/docker/nat" "github.com/docker/docker/runconfig" ) -func migratePortMappings(config *runconfig.Config, hostConfig *runconfig.HostConfig) error { - if config.PortSpecs != nil { - ports, bindings, err := nat.ParsePortSpecs(config.PortSpecs) - if err != nil { - return err - } - config.PortSpecs = nil - if len(bindings) > 0 { - if hostConfig == nil { - hostConfig = &runconfig.HostConfig{} - } - hostConfig.PortBindings = bindings - } - - if config.ExposedPorts == nil { - config.ExposedPorts = make(nat.PortSet, len(ports)) - } - for k, v := range ports { - config.ExposedPorts[k] = v - } - } - return nil -} - func mergeLxcConfIntoOptions(hostConfig *runconfig.HostConfig) ([]string, error) { if hostConfig == nil { return nil, nil diff --git a/docs/man/docker-inspect.1.md b/docs/man/docker-inspect.1.md index 6f3cf51221..a8a2d8f493 100644 --- a/docs/man/docker-inspect.1.md +++ b/docs/man/docker-inspect.1.md @@ -61,7 +61,6 @@ To get information on a container use its ID or instance name: "NetworkDisabled": false, "OnBuild": null, "OpenStdin": false, - "PortSpecs": null, "StdinOnce": false, "Tty": true, "User": "", @@ -215,7 +214,6 @@ on it. "NetworkDisabled": false, "OnBuild": [], "OpenStdin": false, - "PortSpecs": null, "StdinOnce": false, "Tty": false, "User": "", @@ -247,7 +245,6 @@ on it. "NetworkDisabled": false, "OnBuild": [], "OpenStdin": false, - "PortSpecs": null, "StdinOnce": false, "Tty": false, "User": "", diff --git a/docs/sources/reference/api/docker_remote_api_v1.19.md b/docs/sources/reference/api/docker_remote_api_v1.19.md index 458d17479c..467dafb4c4 100644 --- a/docs/sources/reference/api/docker_remote_api_v1.19.md +++ b/docs/sources/reference/api/docker_remote_api_v1.19.md @@ -333,7 +333,6 @@ Return low-level information on the container `id` "NetworkDisabled": false, "OnBuild": null, "OpenStdin": false, - "PortSpecs": null, "StdinOnce": false, "Tty": false, "User": "", @@ -1346,7 +1345,6 @@ Return low-level information on the image `name` "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, - "PortSpecs": null, "Tty": true, "OpenStdin": true, "StdinOnce": false, @@ -1741,7 +1739,6 @@ Create a new image from a container's changes "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, - "PortSpecs": null, "Tty": false, "OpenStdin": false, "StdinOnce": false, @@ -2095,7 +2092,6 @@ Return low-level information about the `exec` command `id`. "AttachStdin" : false, "AttachStdout" : false, "AttachStderr" : false, - "PortSpecs" : null, "ExposedPorts" : null, "Tty" : false, "OpenStdin" : false, diff --git a/docs/sources/reference/api/registry_api.md b/docs/sources/reference/api/registry_api.md index 13a51356f0..5977f9147d 100644 --- a/docs/sources/reference/api/registry_api.md +++ b/docs/sources/reference/api/registry_api.md @@ -176,7 +176,6 @@ Put image for a given `image_id` AttachStdin: false, AttachStdout: false, AttachStderr: false, - PortSpecs: null, Tty: false, OpenStdin: false, StdinOnce: false, @@ -252,7 +251,6 @@ Parameters: AttachStdin: false, AttachStdout: false, AttachStderr: false, - PortSpecs: null, Tty: false, OpenStdin: false, StdinOnce: false, diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index daec87c497..64ce927ef1 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -842,7 +842,6 @@ func (s *DockerSuite) TestContainerApiPostCreateNull(c *check.C) { "AttachStdin":true, "AttachStdout":true, "AttachStderr":true, - "PortSpecs":null, "ExposedPorts":{}, "Tty":true, "OpenStdin":true, diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index c6a777fdd7..36e3f013d5 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -2406,31 +2406,6 @@ func (s *DockerSuite) TestBuildExposeUpperCaseProto(c *check.C) { } } -func (s *DockerSuite) TestBuildExposeHostPort(c *check.C) { - // start building docker file with ip:hostPort:containerPort - name := "testbuildexpose" - expected := "map[5678/tcp:{}]" - _, out, err := buildImageWithOut(name, - `FROM scratch - EXPOSE 192.168.1.2:2375:5678`, - true) - if err != nil { - c.Fatal(err) - } - - if !strings.Contains(out, "to map host ports to container ports (ip:hostPort:containerPort) is deprecated.") { - c.Fatal("Missing warning message") - } - - res, err := inspectField(name, "Config.ExposedPorts") - if err != nil { - c.Fatal(err) - } - if res != expected { - c.Fatalf("Exposed ports %s, expected %s", res, expected) - } -} - func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) { name := "testbuildentrypointinheritance" name2 := "testbuildentrypointinheritance2" diff --git a/pkg/tarsum/tarsum_test.go b/pkg/tarsum/tarsum_test.go index 968d7c7cf1..a99585ef23 100644 --- a/pkg/tarsum/tarsum_test.go +++ b/pkg/tarsum/tarsum_test.go @@ -32,33 +32,33 @@ var testLayers = []testLayer{ filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar", jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json", version: Version0, - tarsum: "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"}, + tarsum: "tarsum+sha256:4095cc12fa5fdb1ab2760377e1cd0c4ecdd3e61b4f9b82319d96fcea6c9a41c6"}, { filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar", jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json", version: VersionDev, - tarsum: "tarsum.dev+sha256:486b86e25c4db4551228154848bc4663b15dd95784b1588980f4ba1cb42e83e9"}, + tarsum: "tarsum.dev+sha256:db56e35eec6ce65ba1588c20ba6b1ea23743b59e81fb6b7f358ccbde5580345c"}, { filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar", jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json", gzip: true, - tarsum: "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"}, + tarsum: "tarsum+sha256:4095cc12fa5fdb1ab2760377e1cd0c4ecdd3e61b4f9b82319d96fcea6c9a41c6"}, { // Tests existing version of TarSum when xattrs are present filename: "testdata/xattr/layer.tar", jsonfile: "testdata/xattr/json", version: Version0, - tarsum: "tarsum+sha256:e86f81a4d552f13039b1396ed03ca968ea9717581f9577ef1876ea6ff9b38c98"}, + tarsum: "tarsum+sha256:07e304a8dbcb215b37649fde1a699f8aeea47e60815707f1cdf4d55d25ff6ab4"}, { // Tests next version of TarSum when xattrs are present filename: "testdata/xattr/layer.tar", jsonfile: "testdata/xattr/json", version: VersionDev, - tarsum: "tarsum.dev+sha256:6235cd3a2afb7501bac541772a3d61a3634e95bc90bb39a4676e2cb98d08390d"}, + tarsum: "tarsum.dev+sha256:6c58917892d77b3b357b0f9ad1e28e1f4ae4de3a8006bd3beb8beda214d8fd16"}, { filename: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar", jsonfile: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json", - tarsum: "tarsum+sha256:ac672ee85da9ab7f9667ae3c32841d3e42f33cc52c273c23341dabba1c8b0c8b"}, + tarsum: "tarsum+sha256:c66bd5ec9f87b8f4c6135ca37684618f486a3dd1d113b138d0a177bfa39c2571"}, { options: &sizedOptions{1, 1024 * 1024, false, false}, // a 1mb file (in memory) tarsum: "tarsum+sha256:8bf12d7e67c51ee2e8306cba569398b1b9f419969521a12ffb9d8875e8836738"}, diff --git a/pkg/tarsum/testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json b/pkg/tarsum/testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json index 0f0ba4974d..48e2af349c 100644 --- a/pkg/tarsum/testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json +++ b/pkg/tarsum/testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json @@ -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} \ No newline at end of file +{"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} \ No newline at end of file diff --git a/pkg/tarsum/testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json b/pkg/tarsum/testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json index 12c18a076f..af57be01ff 100644 --- a/pkg/tarsum/testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json +++ b/pkg/tarsum/testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json @@ -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} \ No newline at end of file +{"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} \ No newline at end of file diff --git a/pkg/tarsum/testdata/xattr/json b/pkg/tarsum/testdata/xattr/json index 328ea31fd9..288441a940 100644 --- a/pkg/tarsum/testdata/xattr/json +++ b/pkg/tarsum/testdata/xattr/json @@ -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} \ No newline at end of file +{"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} \ No newline at end of file diff --git a/registry/registry_mock_test.go b/registry/registry_mock_test.go index d58904d036..60173578c7 100644 --- a/registry/registry_mock_test.go +++ b/registry/registry_mock_test.go @@ -30,7 +30,7 @@ var ( "comment":"test base image","created":"2013-03-23T12:53:11.10432-07:00", "container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0, "CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false, - "PortSpecs":null,"Tty":false,"OpenStdin":false,"StdinOnce":false, + "Tty":false,"OpenStdin":false,"StdinOnce":false, "Env":null,"Cmd":null,"Dns":null,"Image":"","Volumes":null, "VolumesFrom":"","Entrypoint":null},"Size":424242}`, "checksum_simple": "sha256:1ac330d56e05eef6d438586545ceff7550d3bdcb6b19961f12c5ba714ee1bb37", @@ -56,7 +56,7 @@ var ( "comment":"test base image","created":"2013-03-23T12:55:11.10432-07:00", "container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0, "CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false, - "PortSpecs":null,"Tty":false,"OpenStdin":false,"StdinOnce":false, + "Tty":false,"OpenStdin":false,"StdinOnce":false, "Env":null,"Cmd":null,"Dns":null,"Image":"","Volumes":null, "VolumesFrom":"","Entrypoint":null},"Size":424242}`, "checksum_simple": "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2", diff --git a/runconfig/compare.go b/runconfig/compare.go index 1d969e9be8..ebb8ead6c1 100644 --- a/runconfig/compare.go +++ b/runconfig/compare.go @@ -18,7 +18,6 @@ func Compare(a, b *Config) bool { if a.Cmd.Len() != b.Cmd.Len() || len(a.Env) != len(b.Env) || len(a.Labels) != len(b.Labels) || - len(a.PortSpecs) != len(b.PortSpecs) || len(a.ExposedPorts) != len(b.ExposedPorts) || a.Entrypoint.Len() != b.Entrypoint.Len() || len(a.Volumes) != len(b.Volumes) { @@ -42,11 +41,6 @@ func Compare(a, b *Config) bool { return false } } - for i := 0; i < len(a.PortSpecs); i++ { - if a.PortSpecs[i] != b.PortSpecs[i] { - return false - } - } for k := range a.ExposedPorts { if _, exists := b.ExposedPorts[k]; !exists { return false diff --git a/runconfig/config.go b/runconfig/config.go index 13d7189569..e698f3078c 100644 --- a/runconfig/config.go +++ b/runconfig/config.go @@ -113,7 +113,6 @@ type Config struct { AttachStdin bool AttachStdout bool AttachStderr bool - PortSpecs []string // Deprecated - Can be in the format of 8080/tcp ExposedPorts map[nat.Port]struct{} Tty bool // Attach standard streams to a tty, including stdin if it is not closed. OpenStdin bool // Open stdin diff --git a/runconfig/config_test.go b/runconfig/config_test.go index 27727a495e..a0687df3a6 100644 --- a/runconfig/config_test.go +++ b/runconfig/config_test.go @@ -167,25 +167,30 @@ func TestParseRunVolumes(t *testing.T) { func TestCompare(t *testing.T) { volumes1 := make(map[string]struct{}) volumes1["/test1"] = struct{}{} + ports1 := make(nat.PortSet) + ports1[nat.Port("1111/tcp")] = struct{}{} + ports1[nat.Port("2222/tcp")] = struct{}{} config1 := Config{ - PortSpecs: []string{"1111:1111", "2222:2222"}, - Env: []string{"VAR1=1", "VAR2=2"}, - Volumes: volumes1, + ExposedPorts: ports1, + Env: []string{"VAR1=1", "VAR2=2"}, + Volumes: volumes1, } + ports3 := make(nat.PortSet) + ports3[nat.Port("0000/tcp")] = struct{}{} + ports3[nat.Port("2222/tcp")] = struct{}{} config3 := Config{ - PortSpecs: []string{"0000:0000", "2222:2222"}, - Env: []string{"VAR1=1", "VAR2=2"}, - Volumes: volumes1, + ExposedPorts: ports3, + Volumes: volumes1, } volumes2 := make(map[string]struct{}) volumes2["/test2"] = struct{}{} config5 := Config{ - PortSpecs: []string{"0000:0000", "2222:2222"}, - Env: []string{"VAR1=1", "VAR2=2"}, - Volumes: volumes2, + Env: []string{"VAR1=1", "VAR2=2"}, + Volumes: volumes2, } + if Compare(&config1, &config3) { - t.Fatalf("Compare should return false, PortSpecs are different") + t.Fatalf("Compare should return false, ExposedPorts are different") } if Compare(&config1, &config5) { t.Fatalf("Compare should return false, Volumes are different") @@ -199,18 +204,24 @@ func TestMerge(t *testing.T) { volumesImage := make(map[string]struct{}) volumesImage["/test1"] = struct{}{} volumesImage["/test2"] = struct{}{} + portsImage := make(nat.PortSet) + portsImage[nat.Port("1111/tcp")] = struct{}{} + portsImage[nat.Port("2222/tcp")] = struct{}{} configImage := &Config{ - PortSpecs: []string{"1111:1111", "2222:2222"}, - Env: []string{"VAR1=1", "VAR2=2"}, - Volumes: volumesImage, + ExposedPorts: portsImage, + Env: []string{"VAR1=1", "VAR2=2"}, + Volumes: volumesImage, } + portsUser := make(nat.PortSet) + portsUser[nat.Port("2222/tcp")] = struct{}{} + portsUser[nat.Port("3333/tcp")] = struct{}{} volumesUser := make(map[string]struct{}) volumesUser["/test3"] = struct{}{} configUser := &Config{ - PortSpecs: []string{"3333:2222", "3333:3333"}, - Env: []string{"VAR2=3", "VAR3=3"}, - Volumes: volumesUser, + ExposedPorts: portsUser, + Env: []string{"VAR2=3", "VAR3=3"}, + Volumes: volumesUser, } if err := Merge(configUser, configImage); err != nil { diff --git a/runconfig/merge.go b/runconfig/merge.go index 9c9a3b4367..5c30ef9735 100644 --- a/runconfig/merge.go +++ b/runconfig/merge.go @@ -3,7 +3,6 @@ package runconfig import ( "strings" - "github.com/Sirupsen/logrus" "github.com/docker/docker/nat" ) @@ -24,39 +23,6 @@ func Merge(userConf, imageConf *Config) error { } } - if len(userConf.PortSpecs) > 0 { - if userConf.ExposedPorts == nil { - userConf.ExposedPorts = make(nat.PortSet) - } - ports, _, err := nat.ParsePortSpecs(userConf.PortSpecs) - if err != nil { - return err - } - for port := range ports { - if _, exists := userConf.ExposedPorts[port]; !exists { - userConf.ExposedPorts[port] = struct{}{} - } - } - userConf.PortSpecs = nil - } - if len(imageConf.PortSpecs) > 0 { - // FIXME: I think we can safely remove this. Leaving it for now for the sake of reverse-compat paranoia. - logrus.Debugf("Migrating image port specs to container: %s", strings.Join(imageConf.PortSpecs, ", ")) - if userConf.ExposedPorts == nil { - userConf.ExposedPorts = make(nat.PortSet) - } - - ports, _, err := nat.ParsePortSpecs(imageConf.PortSpecs) - if err != nil { - return err - } - for port := range ports { - if _, exists := userConf.ExposedPorts[port]; !exists { - userConf.ExposedPorts[port] = struct{}{} - } - } - } - if len(userConf.Env) == 0 { userConf.Env = imageConf.Env } else { diff --git a/runconfig/parse.go b/runconfig/parse.go index 46ec267851..d5dfc8e66e 100644 --- a/runconfig/parse.go +++ b/runconfig/parse.go @@ -302,7 +302,6 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe config := &Config{ Hostname: hostname, Domainname: domainname, - PortSpecs: nil, // Deprecated ExposedPorts: ports, User: *flUser, Tty: *flTty,