Getty Images

Tip

Why should I use Docker containers vs. VMs for my cloud apps?

Containers and VMs have their own use cases, but one takes the lead in efficiency. Compare the two options, and see how Docker can benefit your cloud applications.

Containers are to VMs what VMs were to physical servers -- a game changer in size, speed and flexibility. Getting familiar with containers at a conceptual level pays dividends on many fronts.

While there remain use cases for VMs, containers and container platforms, such as Docker, will become the de facto way we build and deploy applications. This is due to their scalability, ease of use and portable nature.

Benefits of containers vs. VMs

The advantages of containers over VMs include the following:

  • Speed. Deploying a container from a container image takes seconds. Containers run on the host as a process, and many containers can run on a single host. Within that process is everything that the container needs to function. For example, deploying an Nginx instance takes up less than 200 MB for the image, and memory usage is measured in megabytes, not gigabytes.
  • Scalability. Containers can provide the building blocks of dynamic scaling while adding flexibility. When set behind a load balancer, adding containers to service a spike in requests is trivial. Deployment can become automated and scale out and in quickly. This is what Kubernetes provides: container automation, availability and orchestration.
  • Lower costs. Scaling helps keep costs down, as a container may only exist temporarily before it is shut down and automated. Meanwhile, a group of hosts can manage several container-based application stacks -- no more 1-1 ratios for applications to VMs that all require patching, even when not in use.
  • Portability. Developers can build an image to the required specifications and ship that container image as production-ready. It works identically on another workstation or server if you ensure the container image includes everything needed to run. Docker is best for this, as it runs on all popular platforms.
  • Lightweight. Container images are smaller than VMs since they don't need to include all the OS-related files that use many gigabytes of space. It can be as simple as pulling down an image and running it on a Docker-enabled host.
Compare containers vs. VMs.

Boost cloud app efficiency with Docker

The transition to Docker is a journey toward dynamic provisioning of applications that is more application-centric than the heavyweight approach of VMs. It decouples the application from the hardware.

The Docker container platform utilizes the benefits of containers while improving upon their efficiency. For instance, deploying a new version of a Docker application only takes a single command. There is no need to start updating the environment via scripts, deployment tools or by hand.

Speed up deployment and upgrades

With a VM, you need to manually upgrade or redeploy it. Upgrades may fail, and VMs need to be rebuilt or restored from a backup, which costs time and resources. If a container fails to deploy correctly, delete it, and just pull down a new container image. In that situation, replacement time is seconds, as opposed to hours, of troubleshooting or restoration. There is no point in trying to troubleshoot the container; simply restart a new one in seconds.

Simplify control

An underused feature in standalone host environments is the docker compose parameter. This enables a whole application stack, such as database and application servers, to store and manage all information for the application in a YAML file. Docker compose also enables users to stop and start an entire stack with one command or provide options to the containers' autostart. To start a stack, use docker compose up. To stop a stack, use docker compose down.

Using docker compose pull initiates a read of the YAML configuration file, ensuring that the stack uses the latest available images. By contrast, deploying new VMs or upgrading images is a protracted affair. Docker eliminates these infrastructure requirements, reducing operating costs.

Decrease storage space

What if a newly deployed image contained an issue? Pulling down the previous release of the container is as simple as stopping the faulty container and restarting using the previous container instance. These images are so lightweight that administrators can store several copies without using much disk space.

Stuart Burns is a virtualization expert at a Fortune 500 company. He specializes in VMware and system integration with additional expertise in disaster recovery and systems management. Burns received vExpert status in 2015.

Dig Deeper on Cloud app development and management

Data Center
ITOperations
SearchAWS
SearchVMware
Close