mirror of
https://github.com/moby/moby.git
synced 2025-07-30 18:23:29 +03:00
Remove PortSpecs from Config
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
@ -453,19 +453,11 @@ func expose(b *Builder, args []string, attributes map[string]bool, original stri
|
|||||||
b.Config.ExposedPorts = make(nat.PortSet)
|
b.Config.ExposedPorts = make(nat.PortSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
ports, bindingMap, err := nat.ParsePortSpecs(append(portsTab, b.Config.PortSpecs...))
|
ports, _, err := nat.ParsePortSpecs(portsTab)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// 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
|
// the order is consistent. This prevents cache burst where map ordering
|
||||||
// changes between builds
|
// changes between builds
|
||||||
@ -479,7 +471,6 @@ func expose(b *Builder, args []string, attributes map[string]bool, original stri
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
sort.Strings(portList)
|
sort.Strings(portList)
|
||||||
b.Config.PortSpecs = nil
|
|
||||||
return b.commit("", b.Config.Cmd, fmt.Sprintf("EXPOSE %s", strings.Join(portList, " ")))
|
return b.commit("", b.Config.Cmd, fmt.Sprintf("EXPOSE %s", strings.Join(portList, " ")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,16 +642,6 @@ func (container *Container) buildCreateEndpointOptions() ([]libnetwork.EndpointO
|
|||||||
createOptions []libnetwork.EndpointOption
|
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 {
|
if container.Config.ExposedPorts != nil {
|
||||||
portSpecs = container.Config.ExposedPorts
|
portSpecs = container.Config.ExposedPorts
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ func (daemon *Daemon) Create(config *runconfig.Config, hostConfig *runconfig.Hos
|
|||||||
imgID = img.ID
|
imgID = img.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
if warnings, err = daemon.mergeAndVerifyConfig(config, img); err != nil {
|
if err := daemon.mergeAndVerifyConfig(config, img); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if !config.NetworkDisabled && daemon.SystemConfig().IPv4ForwardingDisabled {
|
if !config.NetworkDisabled && daemon.SystemConfig().IPv4ForwardingDisabled {
|
||||||
|
@ -355,33 +355,16 @@ func (daemon *Daemon) restore() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) checkDeprecatedExpose(config *runconfig.Config) bool {
|
func (daemon *Daemon) mergeAndVerifyConfig(config *runconfig.Config, img *image.Image) error {
|
||||||
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.")
|
|
||||||
}
|
|
||||||
if img != nil && img.Config != nil {
|
if img != nil && img.Config != nil {
|
||||||
if err := runconfig.Merge(config, img.Config); err != nil {
|
if err := runconfig.Merge(config, img.Config); err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if config.Entrypoint.Len() == 0 && config.Cmd.Len() == 0 {
|
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) {
|
func (daemon *Daemon) generateIdAndName(name string) (string, string, error) {
|
||||||
|
@ -5,34 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/nat"
|
|
||||||
"github.com/docker/docker/runconfig"
|
"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) {
|
func mergeLxcConfIntoOptions(hostConfig *runconfig.HostConfig) ([]string, error) {
|
||||||
if hostConfig == nil {
|
if hostConfig == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -61,7 +61,6 @@ To get information on a container use its ID or instance name:
|
|||||||
"NetworkDisabled": false,
|
"NetworkDisabled": false,
|
||||||
"OnBuild": null,
|
"OnBuild": null,
|
||||||
"OpenStdin": false,
|
"OpenStdin": false,
|
||||||
"PortSpecs": null,
|
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"Tty": true,
|
"Tty": true,
|
||||||
"User": "",
|
"User": "",
|
||||||
@ -215,7 +214,6 @@ on it.
|
|||||||
"NetworkDisabled": false,
|
"NetworkDisabled": false,
|
||||||
"OnBuild": [],
|
"OnBuild": [],
|
||||||
"OpenStdin": false,
|
"OpenStdin": false,
|
||||||
"PortSpecs": null,
|
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"Tty": false,
|
"Tty": false,
|
||||||
"User": "",
|
"User": "",
|
||||||
@ -247,7 +245,6 @@ on it.
|
|||||||
"NetworkDisabled": false,
|
"NetworkDisabled": false,
|
||||||
"OnBuild": [],
|
"OnBuild": [],
|
||||||
"OpenStdin": false,
|
"OpenStdin": false,
|
||||||
"PortSpecs": null,
|
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"Tty": false,
|
"Tty": false,
|
||||||
"User": "",
|
"User": "",
|
||||||
|
@ -333,7 +333,6 @@ Return low-level information on the container `id`
|
|||||||
"NetworkDisabled": false,
|
"NetworkDisabled": false,
|
||||||
"OnBuild": null,
|
"OnBuild": null,
|
||||||
"OpenStdin": false,
|
"OpenStdin": false,
|
||||||
"PortSpecs": null,
|
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
"Tty": false,
|
"Tty": false,
|
||||||
"User": "",
|
"User": "",
|
||||||
@ -1346,7 +1345,6 @@ Return low-level information on the image `name`
|
|||||||
"AttachStdin": false,
|
"AttachStdin": false,
|
||||||
"AttachStdout": false,
|
"AttachStdout": false,
|
||||||
"AttachStderr": false,
|
"AttachStderr": false,
|
||||||
"PortSpecs": null,
|
|
||||||
"Tty": true,
|
"Tty": true,
|
||||||
"OpenStdin": true,
|
"OpenStdin": true,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
@ -1741,7 +1739,6 @@ Create a new image from a container's changes
|
|||||||
"AttachStdin": false,
|
"AttachStdin": false,
|
||||||
"AttachStdout": true,
|
"AttachStdout": true,
|
||||||
"AttachStderr": true,
|
"AttachStderr": true,
|
||||||
"PortSpecs": null,
|
|
||||||
"Tty": false,
|
"Tty": false,
|
||||||
"OpenStdin": false,
|
"OpenStdin": false,
|
||||||
"StdinOnce": false,
|
"StdinOnce": false,
|
||||||
@ -2095,7 +2092,6 @@ Return low-level information about the `exec` command `id`.
|
|||||||
"AttachStdin" : false,
|
"AttachStdin" : false,
|
||||||
"AttachStdout" : false,
|
"AttachStdout" : false,
|
||||||
"AttachStderr" : false,
|
"AttachStderr" : false,
|
||||||
"PortSpecs" : null,
|
|
||||||
"ExposedPorts" : null,
|
"ExposedPorts" : null,
|
||||||
"Tty" : false,
|
"Tty" : false,
|
||||||
"OpenStdin" : false,
|
"OpenStdin" : false,
|
||||||
|
@ -176,7 +176,6 @@ Put image for a given `image_id`
|
|||||||
AttachStdin: false,
|
AttachStdin: false,
|
||||||
AttachStdout: false,
|
AttachStdout: false,
|
||||||
AttachStderr: false,
|
AttachStderr: false,
|
||||||
PortSpecs: null,
|
|
||||||
Tty: false,
|
Tty: false,
|
||||||
OpenStdin: false,
|
OpenStdin: false,
|
||||||
StdinOnce: false,
|
StdinOnce: false,
|
||||||
@ -252,7 +251,6 @@ Parameters:
|
|||||||
AttachStdin: false,
|
AttachStdin: false,
|
||||||
AttachStdout: false,
|
AttachStdout: false,
|
||||||
AttachStderr: false,
|
AttachStderr: false,
|
||||||
PortSpecs: null,
|
|
||||||
Tty: false,
|
Tty: false,
|
||||||
OpenStdin: false,
|
OpenStdin: false,
|
||||||
StdinOnce: false,
|
StdinOnce: false,
|
||||||
|
@ -842,7 +842,6 @@ func (s *DockerSuite) TestContainerApiPostCreateNull(c *check.C) {
|
|||||||
"AttachStdin":true,
|
"AttachStdin":true,
|
||||||
"AttachStdout":true,
|
"AttachStdout":true,
|
||||||
"AttachStderr":true,
|
"AttachStderr":true,
|
||||||
"PortSpecs":null,
|
|
||||||
"ExposedPorts":{},
|
"ExposedPorts":{},
|
||||||
"Tty":true,
|
"Tty":true,
|
||||||
"OpenStdin":true,
|
"OpenStdin":true,
|
||||||
|
@ -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) {
|
func (s *DockerSuite) TestBuildEmptyEntrypointInheritance(c *check.C) {
|
||||||
name := "testbuildentrypointinheritance"
|
name := "testbuildentrypointinheritance"
|
||||||
name2 := "testbuildentrypointinheritance2"
|
name2 := "testbuildentrypointinheritance2"
|
||||||
|
@ -32,33 +32,33 @@ var testLayers = []testLayer{
|
|||||||
filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
|
filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
|
||||||
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
||||||
version: Version0,
|
version: Version0,
|
||||||
tarsum: "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"},
|
tarsum: "tarsum+sha256:4095cc12fa5fdb1ab2760377e1cd0c4ecdd3e61b4f9b82319d96fcea6c9a41c6"},
|
||||||
{
|
{
|
||||||
filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
|
filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
|
||||||
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
||||||
version: VersionDev,
|
version: VersionDev,
|
||||||
tarsum: "tarsum.dev+sha256:486b86e25c4db4551228154848bc4663b15dd95784b1588980f4ba1cb42e83e9"},
|
tarsum: "tarsum.dev+sha256:db56e35eec6ce65ba1588c20ba6b1ea23743b59e81fb6b7f358ccbde5580345c"},
|
||||||
{
|
{
|
||||||
filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
|
filename: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/layer.tar",
|
||||||
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
||||||
gzip: true,
|
gzip: true,
|
||||||
tarsum: "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"},
|
tarsum: "tarsum+sha256:4095cc12fa5fdb1ab2760377e1cd0c4ecdd3e61b4f9b82319d96fcea6c9a41c6"},
|
||||||
{
|
{
|
||||||
// Tests existing version of TarSum when xattrs are present
|
// Tests existing version of TarSum when xattrs are present
|
||||||
filename: "testdata/xattr/layer.tar",
|
filename: "testdata/xattr/layer.tar",
|
||||||
jsonfile: "testdata/xattr/json",
|
jsonfile: "testdata/xattr/json",
|
||||||
version: Version0,
|
version: Version0,
|
||||||
tarsum: "tarsum+sha256:e86f81a4d552f13039b1396ed03ca968ea9717581f9577ef1876ea6ff9b38c98"},
|
tarsum: "tarsum+sha256:07e304a8dbcb215b37649fde1a699f8aeea47e60815707f1cdf4d55d25ff6ab4"},
|
||||||
{
|
{
|
||||||
// Tests next version of TarSum when xattrs are present
|
// Tests next version of TarSum when xattrs are present
|
||||||
filename: "testdata/xattr/layer.tar",
|
filename: "testdata/xattr/layer.tar",
|
||||||
jsonfile: "testdata/xattr/json",
|
jsonfile: "testdata/xattr/json",
|
||||||
version: VersionDev,
|
version: VersionDev,
|
||||||
tarsum: "tarsum.dev+sha256:6235cd3a2afb7501bac541772a3d61a3634e95bc90bb39a4676e2cb98d08390d"},
|
tarsum: "tarsum.dev+sha256:6c58917892d77b3b357b0f9ad1e28e1f4ae4de3a8006bd3beb8beda214d8fd16"},
|
||||||
{
|
{
|
||||||
filename: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar",
|
filename: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar",
|
||||||
jsonfile: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json",
|
jsonfile: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json",
|
||||||
tarsum: "tarsum+sha256:ac672ee85da9ab7f9667ae3c32841d3e42f33cc52c273c23341dabba1c8b0c8b"},
|
tarsum: "tarsum+sha256:c66bd5ec9f87b8f4c6135ca37684618f486a3dd1d113b138d0a177bfa39c2571"},
|
||||||
{
|
{
|
||||||
options: &sizedOptions{1, 1024 * 1024, false, false}, // a 1mb file (in memory)
|
options: &sizedOptions{1, 1024 * 1024, false, false}, // a 1mb file (in memory)
|
||||||
tarsum: "tarsum+sha256:8bf12d7e67c51ee2e8306cba569398b1b9f419969521a12ffb9d8875e8836738"},
|
tarsum: "tarsum+sha256:8bf12d7e67c51ee2e8306cba569398b1b9f419969521a12ffb9d8875e8836738"},
|
||||||
|
@ -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}
|
{"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}
|
@ -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}
|
{"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}
|
2
pkg/tarsum/testdata/xattr/json
vendored
2
pkg/tarsum/testdata/xattr/json
vendored
@ -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}
|
{"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}
|
@ -30,7 +30,7 @@ var (
|
|||||||
"comment":"test base image","created":"2013-03-23T12:53:11.10432-07:00",
|
"comment":"test base image","created":"2013-03-23T12:53:11.10432-07:00",
|
||||||
"container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0,
|
"container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0,
|
||||||
"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,
|
"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,
|
"Env":null,"Cmd":null,"Dns":null,"Image":"","Volumes":null,
|
||||||
"VolumesFrom":"","Entrypoint":null},"Size":424242}`,
|
"VolumesFrom":"","Entrypoint":null},"Size":424242}`,
|
||||||
"checksum_simple": "sha256:1ac330d56e05eef6d438586545ceff7550d3bdcb6b19961f12c5ba714ee1bb37",
|
"checksum_simple": "sha256:1ac330d56e05eef6d438586545ceff7550d3bdcb6b19961f12c5ba714ee1bb37",
|
||||||
@ -56,7 +56,7 @@ var (
|
|||||||
"comment":"test base image","created":"2013-03-23T12:55:11.10432-07:00",
|
"comment":"test base image","created":"2013-03-23T12:55:11.10432-07:00",
|
||||||
"container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0,
|
"container_config":{"Hostname":"","User":"","Memory":0,"MemorySwap":0,
|
||||||
"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,
|
"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,
|
"Env":null,"Cmd":null,"Dns":null,"Image":"","Volumes":null,
|
||||||
"VolumesFrom":"","Entrypoint":null},"Size":424242}`,
|
"VolumesFrom":"","Entrypoint":null},"Size":424242}`,
|
||||||
"checksum_simple": "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2",
|
"checksum_simple": "sha256:bea7bf2e4bacd479344b737328db47b18880d09096e6674165533aa994f5e9f2",
|
||||||
|
@ -18,7 +18,6 @@ func Compare(a, b *Config) bool {
|
|||||||
if a.Cmd.Len() != b.Cmd.Len() ||
|
if a.Cmd.Len() != b.Cmd.Len() ||
|
||||||
len(a.Env) != len(b.Env) ||
|
len(a.Env) != len(b.Env) ||
|
||||||
len(a.Labels) != len(b.Labels) ||
|
len(a.Labels) != len(b.Labels) ||
|
||||||
len(a.PortSpecs) != len(b.PortSpecs) ||
|
|
||||||
len(a.ExposedPorts) != len(b.ExposedPorts) ||
|
len(a.ExposedPorts) != len(b.ExposedPorts) ||
|
||||||
a.Entrypoint.Len() != b.Entrypoint.Len() ||
|
a.Entrypoint.Len() != b.Entrypoint.Len() ||
|
||||||
len(a.Volumes) != len(b.Volumes) {
|
len(a.Volumes) != len(b.Volumes) {
|
||||||
@ -42,11 +41,6 @@ func Compare(a, b *Config) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := 0; i < len(a.PortSpecs); i++ {
|
|
||||||
if a.PortSpecs[i] != b.PortSpecs[i] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for k := range a.ExposedPorts {
|
for k := range a.ExposedPorts {
|
||||||
if _, exists := b.ExposedPorts[k]; !exists {
|
if _, exists := b.ExposedPorts[k]; !exists {
|
||||||
return false
|
return false
|
||||||
|
@ -113,7 +113,6 @@ type Config struct {
|
|||||||
AttachStdin bool
|
AttachStdin bool
|
||||||
AttachStdout bool
|
AttachStdout bool
|
||||||
AttachStderr bool
|
AttachStderr bool
|
||||||
PortSpecs []string // Deprecated - Can be in the format of 8080/tcp
|
|
||||||
ExposedPorts map[nat.Port]struct{}
|
ExposedPorts map[nat.Port]struct{}
|
||||||
Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
|
Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
|
||||||
OpenStdin bool // Open stdin
|
OpenStdin bool // Open stdin
|
||||||
|
@ -167,25 +167,30 @@ func TestParseRunVolumes(t *testing.T) {
|
|||||||
func TestCompare(t *testing.T) {
|
func TestCompare(t *testing.T) {
|
||||||
volumes1 := make(map[string]struct{})
|
volumes1 := make(map[string]struct{})
|
||||||
volumes1["/test1"] = struct{}{}
|
volumes1["/test1"] = struct{}{}
|
||||||
|
ports1 := make(nat.PortSet)
|
||||||
|
ports1[nat.Port("1111/tcp")] = struct{}{}
|
||||||
|
ports1[nat.Port("2222/tcp")] = struct{}{}
|
||||||
config1 := Config{
|
config1 := Config{
|
||||||
PortSpecs: []string{"1111:1111", "2222:2222"},
|
ExposedPorts: ports1,
|
||||||
Env: []string{"VAR1=1", "VAR2=2"},
|
Env: []string{"VAR1=1", "VAR2=2"},
|
||||||
Volumes: volumes1,
|
Volumes: volumes1,
|
||||||
}
|
}
|
||||||
|
ports3 := make(nat.PortSet)
|
||||||
|
ports3[nat.Port("0000/tcp")] = struct{}{}
|
||||||
|
ports3[nat.Port("2222/tcp")] = struct{}{}
|
||||||
config3 := Config{
|
config3 := Config{
|
||||||
PortSpecs: []string{"0000:0000", "2222:2222"},
|
ExposedPorts: ports3,
|
||||||
Env: []string{"VAR1=1", "VAR2=2"},
|
Volumes: volumes1,
|
||||||
Volumes: volumes1,
|
|
||||||
}
|
}
|
||||||
volumes2 := make(map[string]struct{})
|
volumes2 := make(map[string]struct{})
|
||||||
volumes2["/test2"] = struct{}{}
|
volumes2["/test2"] = struct{}{}
|
||||||
config5 := Config{
|
config5 := Config{
|
||||||
PortSpecs: []string{"0000:0000", "2222:2222"},
|
Env: []string{"VAR1=1", "VAR2=2"},
|
||||||
Env: []string{"VAR1=1", "VAR2=2"},
|
Volumes: volumes2,
|
||||||
Volumes: volumes2,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if Compare(&config1, &config3) {
|
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) {
|
if Compare(&config1, &config5) {
|
||||||
t.Fatalf("Compare should return false, Volumes are different")
|
t.Fatalf("Compare should return false, Volumes are different")
|
||||||
@ -199,18 +204,24 @@ func TestMerge(t *testing.T) {
|
|||||||
volumesImage := make(map[string]struct{})
|
volumesImage := make(map[string]struct{})
|
||||||
volumesImage["/test1"] = struct{}{}
|
volumesImage["/test1"] = struct{}{}
|
||||||
volumesImage["/test2"] = struct{}{}
|
volumesImage["/test2"] = struct{}{}
|
||||||
|
portsImage := make(nat.PortSet)
|
||||||
|
portsImage[nat.Port("1111/tcp")] = struct{}{}
|
||||||
|
portsImage[nat.Port("2222/tcp")] = struct{}{}
|
||||||
configImage := &Config{
|
configImage := &Config{
|
||||||
PortSpecs: []string{"1111:1111", "2222:2222"},
|
ExposedPorts: portsImage,
|
||||||
Env: []string{"VAR1=1", "VAR2=2"},
|
Env: []string{"VAR1=1", "VAR2=2"},
|
||||||
Volumes: volumesImage,
|
Volumes: volumesImage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
portsUser := make(nat.PortSet)
|
||||||
|
portsUser[nat.Port("2222/tcp")] = struct{}{}
|
||||||
|
portsUser[nat.Port("3333/tcp")] = struct{}{}
|
||||||
volumesUser := make(map[string]struct{})
|
volumesUser := make(map[string]struct{})
|
||||||
volumesUser["/test3"] = struct{}{}
|
volumesUser["/test3"] = struct{}{}
|
||||||
configUser := &Config{
|
configUser := &Config{
|
||||||
PortSpecs: []string{"3333:2222", "3333:3333"},
|
ExposedPorts: portsUser,
|
||||||
Env: []string{"VAR2=3", "VAR3=3"},
|
Env: []string{"VAR2=3", "VAR3=3"},
|
||||||
Volumes: volumesUser,
|
Volumes: volumesUser,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := Merge(configUser, configImage); err != nil {
|
if err := Merge(configUser, configImage); err != nil {
|
||||||
|
@ -3,7 +3,6 @@ package runconfig
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/docker/docker/nat"
|
"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 {
|
if len(userConf.Env) == 0 {
|
||||||
userConf.Env = imageConf.Env
|
userConf.Env = imageConf.Env
|
||||||
} else {
|
} else {
|
||||||
|
@ -302,7 +302,6 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
|
|||||||
config := &Config{
|
config := &Config{
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
Domainname: domainname,
|
Domainname: domainname,
|
||||||
PortSpecs: nil, // Deprecated
|
|
||||||
ExposedPorts: ports,
|
ExposedPorts: ports,
|
||||||
User: *flUser,
|
User: *flUser,
|
||||||
Tty: *flTty,
|
Tty: *flTty,
|
||||||
|
Reference in New Issue
Block a user