运行 Windows 容器时,如何为 Docker for Windows 使用的 Windows VM 分配更多内存?

问题描述 投票:0回答:3

我的镜像的 Dockerfile 现在非常简单:

FROM openjdk:11.0-windowsservercore-ltsc2016
RUN mkdir artifactory
ADD artifactory-pro-6.3.3 artifactory/
# systeminfo for debugging purposes only
RUN systeminfo
RUN C:\\artifactory\bin\artifactory

systeminfo 调用的输出包括以下内容:

OS Name:                   Microsoft Windows Server 2016 Datacenter
OS Version:                10.0.14393 N/A Build 14393
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Server
OS Build Type:             Multiprocessor Free
Registered Owner:          N/A
Registered Organization:   N/A
Original Install Date:     12/5/2018, 4:52:49 PM
System Boot Time:          1/8/2019, 11:19:36 AM
System Manufacturer:       Microsoft Corporation
System Model:              Virtual Machine
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 85 Stepping 4 GenuineIntel ~3696 Mhz
BIOS Version:              Microsoft Corporation Hyper-V UEFI Release v2.5, 5/2/2018
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              N/A
Time Zone:                 (UTC-06:00) Central Time (US & Canada)
Total Physical Memory:     1,023 MB
Available Physical Memory: 597 MB
Virtual Memory: Max Size:  1,023 MB
Virtual Memory: Available: 612 MB
Virtual Memory: In Use:    411 MB
Page File Location(s):     N/A
Domain:                    WORKGROUP
Logon Server:              N/A
Hotfix(s):                 3 Hotfix(s) Installed.
                           [01]: KB4132216
                           [02]: KB4465659
                           [03]: KB4471321
Network Card(s):           N/A
Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed.

如您所见,“Virtual Memory: Max Size”和“Total Physical Memory”属性设置为仅为 1023 MB。我的 docker info 包括以下内容:

Containers: 24
 Running: 0
 Paused: 0
 Stopped: 24
Images: 35
Server Version: 18.03.1-ce
Storage Driver: lcow (linux) windowsfilter (windows)
 LCOW:
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: ics l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 16299 (16299.637.amd64fre.rs3_release_svc.180808-1748)
Operating System: Windows 10 Enterprise
OSType: windows
Architecture: x86_64
CPUs: 16
Total Memory: 31.68GiB

我正在使用以下命令启动我的容器:

docker run -it --name testing -m 8G artifactory-server:latest

然而似乎只有 1G 可用。这是有问题的,因为当我尝试启动 Artifactory 时,Java 运行时环境内存不足,并且容器没有启动。

这是我第一次涉足 Docker for Windows,所以我可能配置有误。我遇到的潜在解决方案引用了 VirtualBox,由于它与 Hyper-V 和运行的 Windows 容器不兼容,我没有。

我没有看到其他人似乎看到的“高级”设置,这让我怀疑我是否拥有正确版本的 Docker。 Here is a picture of what I see.

编辑:经研究,我在“设置”菜单中看不到“共享驱动器”、“网络”和“Kubernetes”选项卡的原因似乎是因为它们仅适用于 Linux 容器。

任何方向将不胜感激。

谢谢!

docker dockerfile artifactory hyper-v docker-for-windows
3个回答
0
投票

我正在为 Windows 使用 docker 桌面(使用 hyper-v)。 更改内存的步骤:

  1. 右键单击docker桌面图标。

  2. 设置

  3. 资源

  4. ADVANCED 您可以在此子页面中更改 cpus/memory/swap。

  5. 应用并重新启动。

  6. 查看效果:


0
投票

您应该将 Windows/Docker 更新到最新版本。在我的设置中,Windows 版本 22H2(OS Build 19045.2604)和 Docker 版本

docker version

    Client:
     Cloud integration: v1.0.29
     Version:           20.10.22
     API version:       1.41
     Go version:        go1.18.9
     Git commit:        3a2c30b
     Built:             Thu Dec 15 22:36:18 2022
     OS/Arch:           windows/amd64
     Context:           default
     Experimental:      true
    
    Server: Docker Desktop 4.16.3 (96739)
     Engine:
      Version:          20.10.22
      API version:      1.41 (minimum version 1.24)
      Go version:       go1.18.9
      Git commit:       42c8b31
      Built:            Thu Dec 15 22:31:10 2022
      OS/Arch:          windows/amd64
      Experimental:     false

-m 8G
开关工作正常:

docker run --rm -m 8G openjdk:11.0-windowsservercore-ltsc2016 systeminfo
    
    Host Name:                 AB026167DB57
    OS Name:                   Microsoft Windows Server 2016 Datacenter
    OS Version:                10.0.14393 N/A Build 14393
    OS Manufacturer:           Microsoft Corporation
    OS Configuration:          Standalone Server
    OS Build Type:             Multiprocessor Free
    Registered Owner:          N/A
    Registered Organization:   N/A
    Product ID:                00377-90000-00001-AA523
    Original Install Date:     1/6/2022, 6:35:40 PM
    System Boot Time:          2/24/2023, 7:42:54 AM
    System Manufacturer:       Microsoft Corporation
    System Model:              Virtual Machine
    System Type:               x64-based PC
    Processor(s):              1 Processor(s) Installed.
                               [01]: Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~2904 Mhz
    BIOS Version:              Microsoft Corporation Hyper-V UEFI Release v4.0, 11/1/2019
    Windows Directory:         C:\Windows
    System Directory:          C:\Windows\system32
    Boot Device:               \Device\HarddiskVolume1
    System Locale:             en-us;English (United States)
    Input Locale:              N/A
    Time Zone:                 N/A
    Total Physical Memory:     8,703 MB
                               ^^^^^^^^
    Available Physical Memory: 8,230 MB
    Virtual Memory: Max Size:  8,703 MB
                               ^^^^^^^^
    Virtual Memory: Available: 8,222 MB
    Virtual Memory: In Use:    481 MB
    Page File Location(s):     N/A
    Domain:                    WORKGROUP
    Logon Server:              N/A
    Hotfix(s):                 4 Hotfix(s) Installed.
                               [01]: KB4054590
                               [02]: KB4132216
                               [03]: KB5005698
                               [04]: KB5009546
    Network Card(s):           N/A
    Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed.

-1
投票

在 docker 守护程序设置的“高级”部分,您可以更新内存和 CPU 设置:

你可以在这里看到所有的细节

© www.soinside.com 2019 - 2024. All rights reserved.