Merge pull request #2492 from dotcloud/publish-all-flag

Add -P flag to publish all exposed ports
This commit is contained in:
Michael Crosby 2013-11-01 10:21:02 -07:00
commit 65ba2868d7
2 changed files with 7 additions and 0 deletions

View File

@ -98,6 +98,7 @@ type HostConfig struct {
LxcConf []KeyValuePair
PortBindings map[Port][]PortBinding
Links []string
PublishAllPorts bool
}
type BindMap struct {
@ -169,6 +170,7 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig,
flAutoRemove := cmd.Bool("rm", false, "Automatically remove the container when it exits (incompatible with -d)")
cmd.Bool("sig-proxy", true, "Proxify all received signal to the process (even in non-tty mode)")
cmd.String("name", "", "Assign a name to the container")
flPublishAll := cmd.Bool("P", false, "Publish all exposed ports to the host interfaces")
if capabilities != nil && *flMemory > 0 && !capabilities.MemoryLimit {
//fmt.Fprintf(stdout, "WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n")
@ -328,6 +330,7 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig,
LxcConf: lxcConf,
PortBindings: portBindings,
Links: flLinks,
PublishAllPorts: *flPublishAll,
}
if capabilities != nil && *flMemory > 0 && !capabilities.SwapLimit {
@ -1112,6 +1115,9 @@ func (container *Container) allocateNetwork(hostConfig *HostConfig) error {
for port := range portSpecs {
binding := bindings[port]
if hostConfig.PublishAllPorts && len(binding) == 0 {
binding = append(binding, PortBinding{})
}
for i := 0; i < len(binding); i++ {
b := binding[i]
nat, err := iface.AllocatePort(port, b)

View File

@ -584,6 +584,7 @@ network communication.
-expose=[]: Expose a port from the container without publishing it to your host
-link="": Add link to another container (name:alias)
-name="": Assign the specified name to the container. If no name is specific docker will generate a random name
-P=false: Publish all exposed ports to the host interfaces
Examples
--------