浏览代码

add check for memoryswap when create

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Qiang Huang 10 年之前
父节点
当前提交
72f356be6a
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      daemon/create.go

+ 3 - 0
daemon/create.go

@@ -33,6 +33,9 @@ func (daemon *Daemon) ContainerCreate(job *engine.Job) engine.Status {
 	if config.Memory > 0 && config.MemorySwap > 0 && config.MemorySwap < config.Memory {
 		return job.Errorf("Minimum memoryswap limit should be larger than memory limit, see usage.\n")
 	}
+	if config.Memory == 0 && config.MemorySwap > 0 {
+		return job.Errorf("You should always set the Memory limit when using Memoryswap limit, see usage.\n")
+	}
 
 	var hostConfig *runconfig.HostConfig
 	if job.EnvExists("HostConfig") {