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

时间:2019-01-08 18:28:24

标签: docker dockerfile artifactory hyper-v docker-for-windows

我的映像的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.

如您所见,“虚拟内存:最大大小”和“总物理内存”属性设置为仅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 Runtime Environment内存不足,并且容器没有启动。

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

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

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

任何方向将不胜感激。

谢谢!

2 个答案:

答案 0 :(得分:2)

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

enter image description here

您可以查看所有详细信息here

答案 1 :(得分:0)

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

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

  2. 设置

  3. 资源

  4. 高级,您可以在此子页面中更改cpus /内存/交换。 enter image description here

  5. 应用并重新启动。

  6. 检查效果:

enter image description here