Browse code

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

Adding more on -m and --memory
(cherry picked from commit c3fbca106552f2dadcb89510ff87945b50f36419)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Vincent Demeester authored on 2017/04/26 22:30:09
Showing 1 changed files
... ...
@@ -745,6 +745,41 @@ PS C:\> docker run -d --isolation default microsoft/nanoserver powershell echo h
745 745
 PS C:\> docker run -d --isolation hyperv microsoft/nanoserver powershell echo hyperv
746 746
 ```
747 747
 
748
+### Specify hard limits on memory available to containers (-m, --memory)
749
+
750
+These parameters always set an upper limit on the memory available to the container. On Linux, this
751
+is set on the cgroup and applications in a container can query it at `/sys/fs/cgroup/memory/memory.limit_in_bytes`.
752
+
753
+On Windows, this will affect containers differently depending on what type of isolation is used.
754
+
755
+- With `process` isolation, Windows will report the full memory of the host system, not the limit to applications running inside the container
756
+    ```powershell
757
+    docker run -it -m 2GB --isolation=process microsoft/nanoserver powershell Get-ComputerInfo *memory*
758
+
759
+    CsTotalPhysicalMemory      : 17064509440
760
+    CsPhyicallyInstalledMemory : 16777216
761
+    OsTotalVisibleMemorySize   : 16664560
762
+    OsFreePhysicalMemory       : 14646720
763
+    OsTotalVirtualMemorySize   : 19154928
764
+    OsFreeVirtualMemory        : 17197440
765
+    OsInUseVirtualMemory       : 1957488
766
+    OsMaxProcessMemorySize     : 137438953344
767
+    ```
768
+- 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."
769
+    ```powershell
770
+    docker run -it -m 2GB --isolation=hyperv microsoft/nanoserver powershell Get-ComputerInfo *memory*
771
+
772
+    CsTotalPhysicalMemory      : 2683355136
773
+    CsPhyicallyInstalledMemory :
774
+    OsTotalVisibleMemorySize   : 2620464
775
+    OsFreePhysicalMemory       : 2306552
776
+    OsTotalVirtualMemorySize   : 2620464
777
+    OsFreeVirtualMemory        : 2356692
778
+    OsInUseVirtualMemory       : 263772
779
+    OsMaxProcessMemorySize     : 137438953344
780
+    ```
781
+
782
+
748 783
 ### Configure namespaced kernel parameters (sysctls) at runtime
749 784
 
750 785
 The `--sysctl` sets namespaced kernel parameters (sysctls) in the