@@ -2810,6 +2810,7 @@ func (c *Container) update(updateOptions *entities.ContainerUpdateOptions) error
28102810 }
28112811 oldRestart := c .config .RestartPolicy
28122812 oldRetries := c .config .RestartRetries
2813+ oldRlimits := c .config .Spec .Process .Rlimits
28132814
28142815 if updateOptions .RestartPolicy != nil {
28152816 if err := define .ValidateRestartPolicy (* updateOptions .RestartPolicy ); err != nil {
@@ -2857,16 +2858,21 @@ func (c *Container) update(updateOptions *entities.ContainerUpdateOptions) error
28572858 c .config .Spec .Process .Env = envLib .Slice (envMap )
28582859 }
28592860
2861+ if updateOptions .Rlimits != nil {
2862+ c .config .Spec .Process .Rlimits = updateOptions .Rlimits
2863+ }
2864+
28602865 if err := c .runtime .state .SafeRewriteContainerConfig (c , "" , "" , c .config ); err != nil {
28612866 // Assume DB write failed, revert to old resources block
28622867 c .config .Spec .Linux .Resources = oldResources
28632868 c .config .RestartPolicy = oldRestart
28642869 c .config .RestartRetries = oldRetries
2870+ c .config .Spec .Process .Rlimits = oldRlimits
28652871 return err
28662872 }
28672873
28682874 if c .ensureState (define .ContainerStateCreated , define .ContainerStateRunning , define .ContainerStatePaused ) &&
2869- (updateOptions .Resources != nil || updateOptions .Env != nil || updateOptions .UnsetEnv != nil ) {
2875+ (updateOptions .Resources != nil || updateOptions .Env != nil || updateOptions .UnsetEnv != nil || updateOptions . Rlimits != nil ) {
28702876 // So `podman inspect` on running containers sources its OCI spec from disk.
28712877 // To keep inspect accurate we need to update the on-disk OCI spec.
28722878 onDiskSpec , err := c .specFromState ()
@@ -2882,6 +2888,9 @@ func (c *Container) update(updateOptions *entities.ContainerUpdateOptions) error
28822888 if len (updateOptions .Env ) != 0 || len (updateOptions .UnsetEnv ) != 0 {
28832889 onDiskSpec .Process .Env = c .config .Spec .Process .Env
28842890 }
2891+ if updateOptions .Rlimits != nil {
2892+ onDiskSpec .Process .Rlimits = updateOptions .Rlimits
2893+ }
28852894 if err := c .saveSpec (onDiskSpec ); err != nil {
28862895 logrus .Errorf ("Unable to update container %s OCI spec - `podman inspect` may not be accurate until container is restarted: %v" , c .ID (), err )
28872896 }
0 commit comments