O'Reilly logo

Docker and Kubernetes for Java Developers by Jaroslaw Krochmalski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Memory

It's worth knowing that, by default, that is, if you use the default settings without any constraints, the running container can use all of the host memory. To change this behavior we can use the --memory (or -m for short) switch for the docker run command. It takes the usual suffixes k, m, or g for kilobytes, megabytes and gigabytes, respectively.

The syntax of the docker run command with memory constraints set will be as follows:

$ docker run -it -m 512m ubuntu  

The preceding command will execute the Ubuntu image with the maximum memory that can be used by the container of half of a gigabyte.

If you do not set the limit on memory that the container can allocate, this can lead to random issues where a single container can easily make ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required