| ... | ... |
@@ -33,6 +33,9 @@ func (daemon *Daemon) ContainerCreate(job *engine.Job) engine.Status {
|
| 33 | 33 |
if config.Memory > 0 && config.MemorySwap > 0 && config.MemorySwap < config.Memory {
|
| 34 | 34 |
return job.Errorf("Minimum memoryswap limit should be larger than memory limit, see usage.\n")
|
| 35 | 35 |
} |
| 36 |
+ if config.Memory == 0 && config.MemorySwap > 0 {
|
|
| 37 |
+ return job.Errorf("You should always set the Memory limit when using Memoryswap limit, see usage.\n")
|
|
| 38 |
+ } |
|
| 36 | 39 |
|
| 37 | 40 |
var hostConfig *runconfig.HostConfig |
| 38 | 41 |
if job.EnvExists("HostConfig") {
|
| ... | ... |
@@ -27,6 +27,7 @@ docker-create - Create a new container |
| 27 | 27 |
[**--link**[=*[]*]] |
| 28 | 28 |
[**--lxc-conf**[=*[]*]] |
| 29 | 29 |
[**-m**|**--memory**[=*MEMORY*]] |
| 30 |
+[**--memory-swap**[=*MEMORY-SWAP*]] |
|
| 30 | 31 |
[**--mac-address**[=*MAC-ADDRESS*]] |
| 31 | 32 |
[**--name**[=*NAME*]] |
| 32 | 33 |
[**--net**[=*"bridge"*]] |
| ... | ... |
@@ -110,6 +111,18 @@ IMAGE [COMMAND] [ARG...] |
| 110 | 110 |
**-m**, **--memory**="" |
| 111 | 111 |
Memory limit (format: <number><optional unit>, where unit = b, k, m or g) |
| 112 | 112 |
|
| 113 |
+ Allows you to constrain the memory available to a container. If the host |
|
| 114 |
+supports swap memory, then the **-m** memory setting can be larger than physical |
|
| 115 |
+RAM. If a limit of 0 is specified (not using **-m**), the container's memory is |
|
| 116 |
+not limited. The actual limit may be rounded up to a multiple of the operating |
|
| 117 |
+system's page size (the value would be very large, that's millions of trillions). |
|
| 118 |
+ |
|
| 119 |
+**--memory-swap**="" |
|
| 120 |
+ Total memory limit (memory + swap) |
|
| 121 |
+ |
|
| 122 |
+ Set `-1` to disable swap (format: <number><optional unit>, where unit = b, k, m or g). |
|
| 123 |
+This value should always larger than **-m**, so you should alway use this with **-m**. |
|
| 124 |
+ |
|
| 113 | 125 |
**--mac-address**="" |
| 114 | 126 |
Container MAC address (e.g. 92:d0:c6:0a:29:33) |
| 115 | 127 |
|
| ... | ... |
@@ -142,7 +155,7 @@ IMAGE [COMMAND] [ARG...] |
| 142 | 142 |
Give extended privileges to this container. The default is *false*. |
| 143 | 143 |
|
| 144 | 144 |
**--read-only**=*true*|*false* |
| 145 |
- Mount the container's root filesystem as read only. |
|
| 145 |
+ Mount the container's root filesystem as read only. |
|
| 146 | 146 |
|
| 147 | 147 |
**--restart**="" |
| 148 | 148 |
Restart policy to apply when a container exits (no, on-failure[:max-retry], always) |
| ... | ... |
@@ -186,16 +186,16 @@ which interface and port to use. |
| 186 | 186 |
Memory limit (format: <number><optional unit>, where unit = b, k, m or g) |
| 187 | 187 |
|
| 188 | 188 |
Allows you to constrain the memory available to a container. If the host |
| 189 |
-supports swap memory, then the -m memory setting can be larger than physical |
|
| 190 |
-RAM. If a limit of 0 is specified, the container's memory is not limited. The |
|
| 191 |
-actual limit may be rounded up to a multiple of the operating system's page |
|
| 192 |
-size, if it is not already. The memory limit should be formatted as follows: |
|
| 193 |
-`<number><optional unit>`, where unit = b, k, m or g. |
|
| 189 |
+supports swap memory, then the **-m** memory setting can be larger than physical |
|
| 190 |
+RAM. If a limit of 0 is specified (not using **-m**), the container's memory is |
|
| 191 |
+not limited. The actual limit may be rounded up to a multiple of the operating |
|
| 192 |
+system's page size (the value would be very large, that's millions of trillions). |
|
| 194 | 193 |
|
| 195 | 194 |
**--memory-swap**="" |
| 196 |
- Total memory usage (memory + swap) |
|
| 195 |
+ Total memory limit (memory + swap) |
|
| 197 | 196 |
|
| 198 |
- Set '-1' to disable swap (format: <number><optional unit>, where unit = b, k, m or g) |
|
| 197 |
+ Set `-1` to disable swap (format: <number><optional unit>, where unit = b, k, m or g). |
|
| 198 |
+This value should always larger than **-m**, so you should alway use this with **-m**. |
|
| 199 | 199 |
|
| 200 | 200 |
**--mac-address**="" |
| 201 | 201 |
Container MAC address (e.g. 92:d0:c6:0a:29:33) |
| ... | ... |
@@ -177,7 +177,8 @@ Json Parameters: |
| 177 | 177 |
for the container. |
| 178 | 178 |
- **User** - A string value containg the user to use inside the container. |
| 179 | 179 |
- **Memory** - Memory limit in bytes. |
| 180 |
-- **MemorySwap**- Total memory usage (memory + swap); set `-1` to disable swap. |
|
| 180 |
+- **MemorySwap**- Total memory limit (memory + swap); set `-1` to disable swap, |
|
| 181 |
+ always use this with `memory`, and make the value larger than `memory`. |
|
| 181 | 182 |
- **CpuShares** - An integer value containing the CPU Shares for container |
| 182 | 183 |
(ie. the relative weight vs othercontainers). |
| 183 | 184 |
**CpuSet** - String value containg the cgroups Cpuset to use. |
| ... | ... |
@@ -310,13 +310,26 @@ The operator can also adjust the performance parameters of the |
| 310 | 310 |
container: |
| 311 | 311 |
|
| 312 | 312 |
-m="": Memory limit (format: <number><optional unit>, where unit = b, k, m or g) |
| 313 |
+ -memory-swap="": Total memory limit (memory + swap, format: <number><optional unit>, where unit = b, k, m or g) |
|
| 313 | 314 |
-c=0 : CPU shares (relative weight) |
| 314 | 315 |
|
| 315 |
-The operator can constrain the memory available to a container easily |
|
| 316 |
-with `docker run -m`. If the host supports swap memory, then the `-m` |
|
| 317 |
-memory setting can be larger than physical RAM. |
|
| 316 |
+We have four ways to set memory usage: |
|
| 317 |
+ - memory=inf, memory-swap=inf (not specify any of them) |
|
| 318 |
+ There is no memory limit, you can use as much as you want. |
|
| 318 | 319 |
|
| 319 |
-Similarly the operator can increase the priority of this container with |
|
| 320 |
+ - memory=L<inf, memory-swap=inf (specify memory and set memory-swap as `-1`) |
|
| 321 |
+ It is not allowed to use more than L bytes of memory, but use as much swap |
|
| 322 |
+ as you want (only if the host supports swap memory). |
|
| 323 |
+ |
|
| 324 |
+ - memory=L<inf, memory-swap=2*L (specify memory without memory-swap) |
|
| 325 |
+ It is not allowed to use more than L bytes of memory, swap *plus* memory |
|
| 326 |
+ usage is double of that. |
|
| 327 |
+ |
|
| 328 |
+ - memory=L<inf, memory-swap=S<inf, L<=S (specify both memory and memory-swap) |
|
| 329 |
+ It is not allowed to use more than L bytes of memory, swap *plus* memory |
|
| 330 |
+ usage is limited by S. |
|
| 331 |
+ |
|
| 332 |
+The operator can increase the priority of this container with |
|
| 320 | 333 |
the `-c` option. By default, all containers run at the same priority and |
| 321 | 334 |
get the same proportion of CPU cycles, but you can tell the kernel to |
| 322 | 335 |
give more shares of CPU time to one or more containers when you start |