It does this by ignoring the memory limitation and writing directly to the disk. Using the swap option allows you to store data even after all RAM assigned to the container has been used up. For example, to limit the container with 1 GB of RAM, add -memory='1g'.įor example, to run an instance of an Ubuntu container and set the memory limit to 1 GB, the command is: sudo docker run -it -memory='1g' ubuntu Set Swap to Disk Memory Limit
The value of memory_limitshould be a positive integer followed by the suffix b, k, m, or g (short for bytes, kilobytes, megabytes, or gigabytes). The command should follow the syntax: sudo docker run -it -memory='' Within the command, specify how much memory you want to dedicate to that specific container. Alternatively, you can use the shortcut -m. To limit the maximum amount of memory usage for a container, add the -memory option to the docker run command. Setting the soft limit for the amount of memory assigned to a container.īelow, find out how to configure Docker memory limitations.Defining the amount of memory a Docker container can swap to disk.Configuring the maximum amount of memory a container can use.There are several RAM limitations you can set for a Docker container. Note: If you still haven’t mastered Docker commands, this Docker Commands Cheat Sheet may be useful as a handy reference sheet.