|
@@ -68,7 +68,7 @@ type Config struct {
|
|
Image string // Name of the image as it was passed by the operator (eg. could be symbolic)
|
|
Image string // Name of the image as it was passed by the operator (eg. could be symbolic)
|
|
}
|
|
}
|
|
|
|
|
|
-func ParseRun(args []string, stdout io.Writer) (*Config, error) {
|
|
|
|
|
|
+func ParseRun(args []string, stdout io.Writer, capabilities *Capabilities) (*Config, error) {
|
|
cmd := rcli.Subcmd(stdout, "run", "[OPTIONS] IMAGE COMMAND [ARG...]", "Run a command in a new container")
|
|
cmd := rcli.Subcmd(stdout, "run", "[OPTIONS] IMAGE COMMAND [ARG...]", "Run a command in a new container")
|
|
if len(args) > 0 && args[0] != "--help" {
|
|
if len(args) > 0 && args[0] != "--help" {
|
|
cmd.SetOutput(ioutil.Discard)
|
|
cmd.SetOutput(ioutil.Discard)
|
|
@@ -83,8 +83,8 @@ func ParseRun(args []string, stdout io.Writer) (*Config, error) {
|
|
flTty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
|
flTty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
|
flMemory := cmd.Int64("m", 0, "Memory limit (in bytes)")
|
|
flMemory := cmd.Int64("m", 0, "Memory limit (in bytes)")
|
|
|
|
|
|
- if *flMemory > 0 && NO_MEMORY_LIMIT {
|
|
|
|
- fmt.Fprintf(stdout, "WARNING: This version of docker has been compiled without memory limit support. Discarding -m.")
|
|
|
|
|
|
+ if *flMemory > 0 && !capabilities.MemoryLimit {
|
|
|
|
+ fmt.Fprintf(stdout, "WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n")
|
|
*flMemory = 0
|
|
*flMemory = 0
|
|
}
|
|
}
|
|
|
|
|
|
@@ -137,6 +137,12 @@ func ParseRun(args []string, stdout io.Writer) (*Config, error) {
|
|
Dns: flDns,
|
|
Dns: flDns,
|
|
Image: image,
|
|
Image: image,
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if *flMemory > 0 && !capabilities.SwapLimit {
|
|
|
|
+ fmt.Fprintf(stdout, "WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n")
|
|
|
|
+ config.MemorySwap = -1
|
|
|
|
+ }
|
|
|
|
+
|
|
// When allocating stdin in attached mode, close stdin at client disconnect
|
|
// When allocating stdin in attached mode, close stdin at client disconnect
|
|
if config.OpenStdin && config.AttachStdin {
|
|
if config.OpenStdin && config.AttachStdin {
|
|
config.StdinOnce = true
|
|
config.StdinOnce = true
|
|
@@ -379,10 +385,15 @@ func (container *Container) Start() error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
- if container.Config.Memory > 0 && NO_MEMORY_LIMIT {
|
|
|
|
- log.Printf("WARNING: This version of docker has been compiled without memory limit support. Discarding the limit.")
|
|
|
|
|
|
+ // Make sure the config is compatible with the current kernel
|
|
|
|
+ if container.Config.Memory > 0 && !container.runtime.capabilities.MemoryLimit {
|
|
|
|
+ log.Printf("WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n")
|
|
container.Config.Memory = 0
|
|
container.Config.Memory = 0
|
|
}
|
|
}
|
|
|
|
+ if container.Config.Memory > 0 && !container.runtime.capabilities.SwapLimit {
|
|
|
|
+ log.Printf("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n")
|
|
|
|
+ container.Config.MemorySwap = -1
|
|
|
|
+ }
|
|
|
|
|
|
if err := container.generateLXCConfig(); err != nil {
|
|
if err := container.generateLXCConfig(); err != nil {
|
|
return err
|
|
return err
|