content_image/981069.jpg
Figure 4-8 shows the difference between VMs and containers. 

<img src='content_image/981069.jpg'>

A key characteristic of a container is that it is small and fast because it uses some of the underlying host operating system’s resources to run rather than containing a whole OS of its own. As such, many more containers can be placed on hardware than VMs. Furthermore, their lightweight nature enables a radically different approach to how they are managed and scaled, which align perfectly with the needs of cloud-native applications. 

Containerization is the act of readying an application for distribution in a container by packaging its various runtime components together. These components include the relevant configuration files, libraries, and software dependencies. The result is a container image that can then be run on a container platform. For more information about this process, see this YouTube video. 

The following sections describe the basic container concepts. 

## Container image 

A container image is the base for every container that you want to run. Container images are built from a Docker file , which is a text file that defines how to build the image and what build artifacts to include in it, such as the app, the app’s configuration, and its dependencies. 

Images are normally made from other images, making them quicker to build. Let someone else do the bulk of the work on an image and then tweak it for your use. 

## Container 

A container is a running instance of a container image. You can make multiple containers from the same image. For example, you might do this to create a set of replicas to scale a container horizontally. Every container is created from an image, so a container is a packaged app with all of its dependencies, and the app can be moved between environments and run without changes. Unlike VMs, the running container does not need to virtualize a device, its operating system, and the underlying hardware. Only the app code, run time, system tools, libraries, and settings are packaged inside the container. Containers run as isolated processes on Linux compute hosts and share the host operating system and its hardware resources. This approach makes a container much more lightweight, portable, and efficient than a VM, and many more containers can be run on a hosts’ resources than can VMs. 

