| ... | ... |
@@ -13,7 +13,10 @@ endif |
| 13 | 13 |
GIT_COMMIT = $(shell git rev-parse --short HEAD) |
| 14 | 14 |
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES") |
| 15 | 15 |
|
| 16 |
-BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS)" |
|
| 16 |
+NO_MEMORY_LIMIT ?= 0 |
|
| 17 |
+export NO_MEMORY_LIMIT |
|
| 18 |
+ |
|
| 19 |
+BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS) -X main.NO_MEMORY_LIMIT $(NO_MEMORY_LIMIT)" |
|
| 17 | 20 |
|
| 18 | 21 |
SRC_DIR := $(GOPATH)/src |
| 19 | 22 |
|
| ... | ... |
@@ -20,7 +20,10 @@ import ( |
| 20 | 20 |
|
| 21 | 21 |
const VERSION = "0.1.4" |
| 22 | 22 |
|
| 23 |
-var GIT_COMMIT string |
|
| 23 |
+var ( |
|
| 24 |
+ GIT_COMMIT string |
|
| 25 |
+ NO_MEMORY_LIMIT bool |
|
| 26 |
+) |
|
| 24 | 27 |
|
| 25 | 28 |
func (srv *Server) Name() string {
|
| 26 | 29 |
return "docker" |
| ... | ... |
@@ -183,6 +186,9 @@ func (srv *Server) CmdWait(stdin io.ReadCloser, stdout io.Writer, args ...string |
| 183 | 183 |
func (srv *Server) CmdVersion(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
| 184 | 184 |
fmt.Fprintf(stdout, "Version:%s\n", VERSION) |
| 185 | 185 |
fmt.Fprintf(stdout, "Git Commit:%s\n", GIT_COMMIT) |
| 186 |
+ if NO_MEMORY_LIMIT {
|
|
| 187 |
+ fmt.Fprintf(stdout, "Memory limit disabled\n") |
|
| 188 |
+ } |
|
| 186 | 189 |
return nil |
| 187 | 190 |
} |
| 188 | 191 |
|
| ... | ... |
@@ -79,6 +79,11 @@ func ParseRun(args []string, stdout io.Writer) (*Config, error) {
|
| 79 | 79 |
flTty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
| 80 | 80 |
flMemory := cmd.Int64("m", 0, "Memory limit (in bytes)")
|
| 81 | 81 |
|
| 82 |
+ if *flMemory > 0 && NO_MEMORY_LIMIT {
|
|
| 83 |
+ fmt.Fprintf(stdout, "WARNING: This version of docker has been compiled without memory limit support. Discarding -m.") |
|
| 84 |
+ *flMemory = 0 |
|
| 85 |
+ } |
|
| 86 |
+ |
|
| 82 | 87 |
var flPorts ListOpts |
| 83 | 88 |
cmd.Var(&flPorts, "p", "Expose a container's port to the host (use 'docker port' to see the actual mapping)") |
| 84 | 89 |
|
| ... | ... |
@@ -355,6 +360,12 @@ func (container *Container) Start() error {
|
| 355 | 355 |
if err := container.allocateNetwork(); err != nil {
|
| 356 | 356 |
return err |
| 357 | 357 |
} |
| 358 |
+ |
|
| 359 |
+ if container.Config.Memory > 0 && NO_MEMORY_LIMIT {
|
|
| 360 |
+ log.Printf("WARNING: This version of docker has been compiled without memory limit support. Discarding the limit.")
|
|
| 361 |
+ container.Config.Memory = 0 |
|
| 362 |
+ } |
|
| 363 |
+ |
|
| 358 | 364 |
if err := container.generateLXCConfig(); err != nil {
|
| 359 | 365 |
return err |
| 360 | 366 |
} |
| ... | ... |
@@ -13,7 +13,10 @@ import ( |
| 13 | 13 |
"syscall" |
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 |
-var GIT_COMMIT string |
|
| 16 |
+var ( |
|
| 17 |
+ GIT_COMMIT string |
|
| 18 |
+ NO_MEMORY_LIMIT string |
|
| 19 |
+) |
|
| 17 | 20 |
|
| 18 | 21 |
func main() {
|
| 19 | 22 |
if docker.SelfPath() == "/sbin/init" {
|
| ... | ... |
@@ -36,11 +39,15 @@ func main() {
|
| 36 | 36 |
os.Setenv("DEBUG", "1")
|
| 37 | 37 |
} |
| 38 | 38 |
docker.GIT_COMMIT = GIT_COMMIT |
| 39 |
+ docker.NO_MEMORY_LIMIT = NO_MEMORY_LIMIT == "1" |
|
| 39 | 40 |
if *flDaemon {
|
| 40 | 41 |
if flag.NArg() != 0 {
|
| 41 | 42 |
flag.Usage() |
| 42 | 43 |
return |
| 43 | 44 |
} |
| 45 |
+ if NO_MEMORY_LIMIT == "1" {
|
|
| 46 |
+ log.Printf("WARNING: This version of docker has been compiled without memory limit support.")
|
|
| 47 |
+ } |
|
| 44 | 48 |
if err := daemon(*pidfile); err != nil {
|
| 45 | 49 |
log.Fatal(err) |
| 46 | 50 |
} |