diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-10-18 15:04:19 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2021-11-12 11:08:25 -0500 |
commit | 8887cc7e449602d5ff371de84e24b83e448d8480 (patch) | |
tree | 8a453129aeb18551551c4244c7b3cf41442ffd72 /pkg/specgenutil | |
parent | 6f779b23002710a74d6f2360ad0dc0029b5eefac (diff) | |
download | podman-8887cc7e449602d5ff371de84e24b83e448d8480.tar.gz podman-8887cc7e449602d5ff371de84e24b83e448d8480.tar.bz2 podman-8887cc7e449602d5ff371de84e24b83e448d8480.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.go | 12 |
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) |