summaryrefslogtreecommitdiff
path: root/pkg/specgenutil
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-10-18 15:04:19 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-10-19 14:06:33 -0400
commit20b5a8599b11269c8812ce6c3df6d7f39ef1930c (patch)
tree40e3e76ac20480d169ca5df9593cfe7e05b24bda /pkg/specgenutil
parent82fd2999b2cd1137bc8fe856b2b9af710e3410f4 (diff)
downloadpodman-20b5a8599b11269c8812ce6c3df6d7f39ef1930c.tar.gz
podman-20b5a8599b11269c8812ce6c3df6d7f39ef1930c.tar.bz2
podman-20b5a8599b11269c8812ce6c3df6d7f39ef1930c.zip
podman run --memory=0 ... should not set memory limit
On Docker this is ignored, and it should be on Podman as well. This is documented in the man page. Fixes: https://github.com/containers/podman/issues/12002 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'pkg/specgenutil')
-rw-r--r--pkg/specgenutil/specgen.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go
index 6a6397257..8007e5d8e 100644
--- a/pkg/specgenutil/specgen.go
+++ b/pkg/specgenutil/specgen.go
@@ -133,12 +133,14 @@ func getMemoryLimits(s *specgen.SpecGenerator, c *entities.ContainerCreateOption
if err != nil {
return nil, errors.Wrapf(err, "invalid value for memory")
}
- memory.Limit = &ml
- if c.MemorySwap == "" {
- limit := 2 * ml
- memory.Swap = &(limit)
+ if ml > 0 {
+ memory.Limit = &ml
+ if c.MemorySwap == "" {
+ limit := 2 * ml
+ memory.Swap = &(limit)
+ }
+ hasLimits = true
}
- hasLimits = true
}
if m := c.MemoryReservation; len(m) > 0 {
mr, err := units.RAMInBytes(m)