mirror of
https://github.com/docker/compose.git
synced 2025-07-27 07:34:10 +02:00
backend.local: Add memory limits
Signed-off-by: Chris Crone <christopher.crone@docker.com>
This commit is contained in:
parent
47aa069a3d
commit
6a9eca9bdf
@ -172,6 +172,7 @@ func containerJSONToHostConfig(m *types.ContainerJSON) *containers.HostConfig {
|
||||
AutoRemove: m.HostConfig.AutoRemove,
|
||||
RestartPolicy: restartPolicy,
|
||||
CPULimit: float64(m.HostConfig.Resources.NanoCPUs) / 1e9,
|
||||
MemoryLimit: uint64(m.HostConfig.Resources.Memory),
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,6 +220,7 @@ func (ms *local) Run(ctx context.Context, r containers.ContainerConfig) error {
|
||||
AutoRemove: r.AutoRemove,
|
||||
Resources: container.Resources{
|
||||
NanoCPUs: int64(r.CPULimit * 1e9),
|
||||
Memory: int64(r.MemLimit),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ func TestToHostConfig(t *testing.T) {
|
||||
},
|
||||
Resources: container.Resources{
|
||||
NanoCPUs: 750000000,
|
||||
Memory: 512 * 1024 * 1024,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -69,6 +70,7 @@ func TestToHostConfig(t *testing.T) {
|
||||
AutoRemove: true,
|
||||
RestartPolicy: containers.RestartPolicyNone,
|
||||
CPULimit: 0.75,
|
||||
MemoryLimit: 512 * 1024 * 1024,
|
||||
}
|
||||
assert.DeepEqual(t, hc, res)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user