Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

docker doesn't use memory or CPU options #145

Closed
gupta-ak opened this issue Sep 22, 2017 · 15 comments
Closed

docker doesn't use memory or CPU options #145

gupta-ak opened this issue Sep 22, 2017 · 15 comments
Assignees

Comments

@gupta-ak
Copy link
Member

For example, if I try running mssql-server-linux image with -m=4g, I get this error sqlservr: This program requires a machine with at least 3250 megabytes of memory.

@PatrickLang
Copy link

PatrickLang commented Oct 6, 2017

This needs an issue in moby/moby. Will probably require changes to moby/moby as well as opengcs

@lowenna lowenna self-assigned this Oct 6, 2017
@lowenna
Copy link
Contributor

lowenna commented Oct 6, 2017

Leave it here for now. It's already on my list.

@edrevo
Copy link

edrevo commented Jan 18, 2018

It would be great if the move to LCOW allowed enabling dynamic memory for Linux containers.

@PatrickLang
Copy link

PatrickLang commented Jan 22, 2018

Good news :) Containers with Hyper-V isolation already allocate memory on-demand so it's more or less comparable to dynamic memory. This option puts a limit on the max memory size which is enforced by the hypervisor. You can see this behavior by looking at the memory usage of vmmem processes on the host. Those are a wrapper to hold the memory used by the container

@PatrickLang
Copy link

ping @jhowardmsft - is this still in the works? do you have an issue in moby/moby yet?

@notanaverageman
Copy link

Is this change as simple as adding the the following code snippet to createLinux function in this file? Or, is there another limitation/option in HCS to be considered?

if spec.Windows.Resources != nil {
	if spec.Windows.Resources.CPU != nil {
		if spec.Windows.Resources.CPU.Count != nil {
			// This check is being done here rather than in adaptContainerSettings
			// because we don't want to update the HostConfig in case this container
			// is moved to a host with more CPUs than this one.
			cpuCount := *spec.Windows.Resources.CPU.Count
			hostCPUCount := uint64(sysinfo.NumCPU())
			if cpuCount > hostCPUCount {
				c.logger.Warnf("Changing requested CPUCount of %d to current number of processors, %d", cpuCount, hostCPUCount)
				cpuCount = hostCPUCount
			}
			configuration.ProcessorCount = uint32(cpuCount)
		}
		if spec.Windows.Resources.CPU.Shares != nil {
			configuration.ProcessorWeight = uint64(*spec.Windows.Resources.CPU.Shares)
		}
		if spec.Windows.Resources.CPU.Maximum != nil {
			configuration.ProcessorMaximum = int64(*spec.Windows.Resources.CPU.Maximum)
		}
	}
	if spec.Windows.Resources.Memory != nil {
		if spec.Windows.Resources.Memory.Limit != nil {
			configuration.MemoryMaximumInMB = int64(*spec.Windows.Resources.Memory.Limit) / 1024 / 1024
		}
	}
	if spec.Windows.Resources.Storage != nil {
		if spec.Windows.Resources.Storage.Bps != nil {
			configuration.StorageBandwidthMaximum = *spec.Windows.Resources.Storage.Bps
		}
		if spec.Windows.Resources.Storage.Iops != nil {
			configuration.StorageIOPSMaximum = *spec.Windows.Resources.Storage.Iops
		}
	}
}

@notanaverageman
Copy link

OK, the previous code does not work. However, if anyone is in need of this, adding a hardcoded value to the docker source code works. Add MemoryMaximumInMB: 4096 to configuration := &hcsshim.ContainerConfig in createLinux function inside client_local_windows.go. Then you can compile and use the patched dockerd.exe

@fizxmike
Copy link

@yusuf-gunaydin I'm going to try this out... have you looked into possibly grabbing the -m parameter from inside createLinux function and applying that number to MemoryMaximumInMB? Maybe this PR does it!?

@brianweet
Copy link

@yusuf-gunaydin thanks for the tip, seems to work :)

@notanaverageman
Copy link

@fizxmike If I recall correctly I have tried the code I posted above, but it didn't work either for CPU or memory or neither. As I needed them both, I hardcoded the CPU and memory values. By the way CPU is also limited to 2 cores, if anyone needs the information.

I couldn't find a good way to debug docker sources. Println debugging and recompiling the whole source every time a small change is made prevents me from trying more.

@kethahel99
Copy link

Is this still being implemented? I'm running Docker Edge

PS C:\Users\C740763> docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 19
Server Version: 18.05.0-ce
Storage Driver: windowsfilter (windows) lcow (linux)
Windows:
LCOW:
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.431.amd64fre.rs3_release_svc_escrow.180502-1908)
Operating System: Windows 10 Enterprise Version 1709 (OS Build 16299.431)
OSType: windows
Architecture: x86_64
CPUs: 8
Total Memory: 15.38GiB
Name: 23360jnbsis126l
ID: OMBQ:JNTL:FTZF:UZSI:72I3:OXGQ:CYD7:VEIT:F5LJ:ZFDO:CFK5:Y3G2
Docker Root Dir: D:\Docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: -1
Goroutines: 28
System Time: 2018-05-23T00:33:26.6804568+02:00
EventsListeners: 2
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

@LukeRH
Copy link

LukeRH commented Jul 26, 2018

Hi, Is there an estimate on when this will be fixed?
Thanks

@Iristyle
Copy link

There is a PR up in Moby at moby/moby#37296 ... but it's unclear how close to approval it is. Some folks have built from source with success.

@jterry75
Copy link
Contributor

@jhowardmsft - None of these asks are OpenGCS specific and indeed the platform already supports them. Its just a config issue in Docker correct? Can we close this to avoid confusion? Or am I missing something fundamental here?

@lowenna
Copy link
Contributor

lowenna commented Dec 3, 2018

@jterry75 Yes, I'm closing it here. The fix needs to go in moby, although maintainers there are not accepting it. There have been several PR attempts in moby to fix.

@lowenna lowenna closed this as completed Dec 3, 2018
@microsoft microsoft locked and limited conversation to collaborators Dec 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests