Book Image

Developing with Docker

By : Jaroslaw Krochmalski, Jarosław Krochmalski
Book Image

Developing with Docker

By: Jaroslaw Krochmalski, Jarosław Krochmalski

Overview of this book

This fast-paced practical guide will get you up and running with Docker. Using Docker, you will be able to build, ship, and run many distributed applications in real time. You will start with quickly installing Docker and start working with images and containers. We will present different types of containers and their applications, and show you how to find and build images. You will learn how you can contribute to the image repository by publishing different images. This will familiarize you with the image building process and you will be able to successfully run your programs within containers. By finishing this book, you will be well equipped in deploying your applications using Docker and will have a clear understanding of concepts, techniques, and practical methods to get it running in production systems.
Table of Contents (16 chapters)
Developing with Docker
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Runtime constraints on resources


It may be useful to restrict the Docker container usage on resources when running. Docker gives you a lot of possibilities to set constraints on the memory, CPU usage or disk access usage. Let's begin with setting the memory constraints.

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 a 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 container of half of gigabyte.

Tip

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