Browse code

Merge pull request #32724 from PatrickLang/patricklang-win-memory

Adding more on -m and --memory

Vincent Demeester authored on 2017/04/26 22:30:09
Showing 1 changed files
... ...
@@ -738,6 +738,41 @@ $ docker run -d --isolation default busybox top
738 738
 $ docker run -d --isolation hyperv busybox top
739 739
 ```
740 740
 
741
+### Specify hard limits on memory available to containers (-m, --memory)
742
+
743
+These parameters always set an upper limit on the memory available to the container. On Linux, this
744
+is set on the cgroup and applications in a container can query it at `/sys/fs/cgroup/memory/memory.limit_in_bytes`.
745
+
746
+On Windows, this will affect containers differently depending on what type of isolation is used.
747
+
748
+- With `process` isolation, Windows will report the full memory of the host system, not the limit to applications running inside the container
749
+    ```powershell
750
+    docker run -it -m 2GB --isolation=process microsoft/nanoserver powershell Get-ComputerInfo *memory*
751
+
752
+    CsTotalPhysicalMemory      : 17064509440
753
+    CsPhyicallyInstalledMemory : 16777216
754
+    OsTotalVisibleMemorySize   : 16664560
755
+    OsFreePhysicalMemory       : 14646720
756
+    OsTotalVirtualMemorySize   : 19154928
757
+    OsFreeVirtualMemory        : 17197440
758
+    OsInUseVirtualMemory       : 1957488
759
+    OsMaxProcessMemorySize     : 137438953344
760
+    ```
761
+- With `hyperv` isolation, Windows will create a utility VM that is big enough to hold the memory limit, plus the minimal OS needed to host the container. That size is reported as "Total Physical Memory."
762
+    ```powershell
763
+    docker run -it -m 2GB --isolation=hyperv microsoft/nanoserver powershell Get-ComputerInfo *memory*
764
+
765
+    CsTotalPhysicalMemory      : 2683355136
766
+    CsPhyicallyInstalledMemory :
767
+    OsTotalVisibleMemorySize   : 2620464
768
+    OsFreePhysicalMemory       : 2306552
769
+    OsTotalVirtualMemorySize   : 2620464
770
+    OsFreeVirtualMemory        : 2356692
771
+    OsInUseVirtualMemory       : 263772
772
+    OsMaxProcessMemorySize     : 137438953344
773
+    ```
774
+
775
+
741 776
 ### Configure namespaced kernel parameters (sysctls) at runtime
742 777
 
743 778
 The `--sysctl` sets namespaced kernel parameters (sysctls) in the