Skip to main content
Your progress
0 of 5 complete0%
Intro / I.5 / L1 OF 4 / Beginner LEVEL / 7 min

From virtual machines to containers

Outcome

By the end of this lesson, you will be able to explain what a container is, how it differs from a virtual machine, and say what each one costs to run.


PrerequisitesI.2 L1, I.4
Time7 minutes

1. Concept

Software is a set of instructions. To be useful, it has to run somewhere. In the cloud there are a few common places to run it, and each one is billed a little differently.

The virtual machine way

The oldest and simplest way is to rent a virtual machine (VM): a slice of a physical computer that behaves like a computer of its own. You install an operating system (the base software, such as Linux or Windows), install your app, and leave it running.

This is like renting a whole flat for one person. It works, but often the flat is much bigger than the person needs. Many VMs spend most of their time using a small part of the power they are paying for.

Billing: per hour the VM is switched on, plus its disk per GB-month. Busy or idle, the hourly price is the same.

The container way

A container is a way of packaging an app together with everything it needs to run (its code, its settings and the small pieces of software it depends on) into one neat bundle. That bundle runs the same way on a developer’s laptop, in a test system and in production.

The packed bundle, ready to be started, is called an image. Images are kept in a registry: a storage service for images. Each provider has one: Amazon ECR on AWS, Artifact Registry on Google Cloud and Azure Container Registry on Azure.

Containers are small and start quickly. Several of them can share one machine, each in its own separate space. Back to the flat: instead of one person per flat, containers are like rooms in a shared house. More people fit in the same building, so less space goes to waste.

What a container is billed on

Here is the point that matters for cost: you do not usually pay for a container itself. Containers run on machines, and you pay for those machines. The container decides how well the machine’s capacity is used, not how it is priced.

So the bill for a container setup usually shows:

  • The machines the containers run on, per hour.
  • The registry, per GB-month for the stored images.
  • Any management service that starts and watches the containers (the next lesson).

Some providers also offer services that run containers for you without you renting the machines underneath, such as AWS Fargate, Google Cloud Run and Azure Container Apps. These charge for the processing power and memory the containers ask for, while they run.


2. Worked example

A team runs four small apps. All prices are illustrative.

Option 1: one VM per app. Four VMs at $0.10 per hour, each mostly idle.

WhatAmountUnit priceMonthly cost
4 VMs, on all month4 x 730 hours$0.10 per hour$292

Option 2: four containers sharing two machines. The apps are packed into containers and placed on two machines of the same size.

WhatAmountUnit priceMonthly cost
2 machines, on all month2 x 730 hours$0.10 per hour$146
Images in a registry10 GB$0.10 per GB-month$1
Total$147

The saving comes from packing the work onto fewer machines, not from containers being free. If the team had kept four machines and simply put one container on each, the bill would be the same as Option 1, plus the registry.


3. Hands-on (5 min: no account needed)

Terminal window
1. Open hub.docker.com, a public registry of container images. No sign-in is needed to browse.
2. Search for "nginx", a popular web server.
3. Open the image page and find the "Tags" tab.
4. Look at the size listed for one tag (often tens of megabytes).
5. Compare that with the size of a typical VM disk, which is often tens of gigabytes.

That size difference is why containers start quickly and why many of them fit on one machine.


4. Knowledge check

Q1

What is a container?

A. A physical box that holds servers in a data centre
B. An app packaged with everything it needs to run
C. A storage bucket for files of any size
D. A discount plan for running many machines

Show answer

Correct: B. A container bundles an app with its code, settings and dependencies so it runs the same anywhere. A describes a rack. C describes object storage. D is not a container at all.

Q2

Containers run on rented machines. What do you usually pay for?

A. The machines they run on, per hour
B. Each container, at a fixed monthly fee
C. Nothing, because containers are free
D. Only the number of lines of code in the app

Show answer

Correct: A. You pay for the machines underneath, plus registry storage. Containers change how well those machines are used, not the price per machine.

Q3

Where are container images kept?

A. On the provider’s billing page
B. Inside the operating system of every laptop
C. In a registry, billed for storage
D. In a region’s availability zone list

Show answer

Correct: C. A registry, such as Amazon ECR, Artifact Registry or Azure Container Registry, stores images and charges per GB-month for them.


5. Apply

When a team says “we moved to containers”, ask how many machines they run now compared with before. Containers save money only when they let the same work fit on fewer machines. If the machine count did not fall, the bill probably did not either.



Start with the bill.

Foundations takes about five hours. The first lesson is nine minutes.

Free curriculum. No paywall. 290 lessons across 7 courses, plus an optional 24-lesson beginner course. Browse every course without an account; a free account opens the lessons, saves your progress and opens the exams for three publicly verifiable credentials. Read it on the train, take the exam on a Saturday, list the credential on your résumé Monday.

5h median time to finish Foundations
free account, every course, no paywall
3 certifications, each with a public verifier
Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console· Multi-cloud automation· Production-ready in 30 min· SOC 2 · ISO 27001· 20–60% off the bill, first month· 4 platforms · 1 console·