Introduction

Welcome to the first lesson of Docker Fundamentals. In this lesson, you will learn what containers are, how they differ from virtual machines, and why developers use them in modern software development. You will also get hands-on experience by running your first container using Docker CLI commands. Since you are working in the CodeSignal environment, Docker is already installed for you. However, it is important to know how to check for Docker on any machine, as you may need to do this on your own computer in the future.

Understanding Docker fundamentals is essential before moving on to Google Cloud Platform (GCP) container services such as Artifact Registry, Cloud Run, and Google Kubernetes Engine (GKE). These services all build on core Docker concepts, so having a solid grasp of how containers work will make it much easier to use and troubleshoot these GCP tools effectively.

By the end of this lesson, you will be able to explain what a container is, describe how containers differ from virtual machines, understand why containers are useful, and run a simple "hello world" container using Docker CLI to confirm Docker is working.

What Is A Container?

A container is a lightweight, isolated environment that allows you to run an application and all its dependencies together. Think of it as a small, self-contained box that holds everything your app needs to work: the code, libraries, and settings. This means your app will run the same way, no matter where you start the container.

To make this idea more concrete, imagine a shipping container. No matter what is inside — a car, electronics, or furniture — the container looks the same from the outside and can be moved easily by ship, train, or truck. In the same way, a software container standardizes how applications are packaged and moved, making it easy to run them anywhere.

Containers Vs. Virtual Machines

You might have heard of virtual machines (VMs) before. Both containers and virtual machines help you run software in isolated environments, but they do it in different ways. A virtual machine includes a full copy of an operating system, the application, and all its dependencies. This makes virtual machines large and slow to start.

Containers, on the other hand, share the host operating system and include only the application and its dependencies. This makes containers much smaller and faster to start. You can think of it like this: if your computer is a building, a virtual machine is like building a new house inside it, while a container is like setting up a new room with everything you need, using the building's existing walls and utilities.

Here's a simple mental model to help you compare:

LayerVirtual MachineContainer
HardwareHostHost
Host OSHost OSHost OS
Virtualization LayerHypervisorContainer Engine (Docker)
Guest OSFull OS per VMNo separate guest OS; shares host kernel
App + DependenciesInside VMInside Container

The diagram below visualizes this layered architecture:

Notice how the virtual machine stack includes a complete Guest OS for each VM, while containers share the host kernel directly through the . This key difference is what makes containers more lightweight and efficient.

Why Developers Use Containers

Containers have become popular because they solve many common problems in software development. Here are some of the key benefits:

  • Portability And Consistency: Containers package an application with all its dependencies, ensuring it runs the same way everywhere. You can build a container on your laptop and be confident it will work identically on a server or in the cloud, eliminating the "it works on my machine" problem.
  • Efficiency And Speed: Because containers share the host operating system, they are much more lightweight and faster than virtual machines. They use fewer resources, start up in seconds, and allow you to run many more applications on a single machine.
  • Simplified Onboarding And Collaboration: New team members can get started quickly by running a pre-configured container, ensuring everyone has an identical development environment. This simplifies collaboration and reduces setup time.

These advantages make containers ideal for common use cases, such as running microservices (small, independent parts of a larger app), automating testing and deployment (CI/CD), and ensuring that local development environments match production.

Getting Hands-On with Docker

Docker is the most popular tool for working with containers. It helps you create, run, and manage containers. With Docker, you use images, which are blueprints for containers. You can download images from a registry (like Docker Hub) and then use them to start containers.

While Docker is pre-installed for you in the CodeSignal environment, you will need to install it on your local machine to work with it outside of this course. The installation process varies depending on your operating system:

  • Windows: Install Docker Desktop for Windows. It requires Windows 10/11 with WSL 2 (Windows Subsystem for Linux).
  • macOS: Install Docker Desktop for Mac, available for both Intel and Apple Silicon chips.
  • Linux: Install Docker Engine. The steps differ based on your distribution (e.g., Ubuntu, CentOS, Debian).

For detailed, up-to-date instructions, always refer to the official Docker documentation.

Verifying the Installation

Before you start working with containers, it is a good idea to check if Docker is installed and working. On your own computer, you would run the following command in your terminal:

If Docker is installed, you will see output similar to this:

If you see a version number, Docker is ready to use.

Running Your First Container: Hello-World

Now, let's run your first container. The hello-world image is a simple test image provided by Docker. To run it, use this command:

When you run this command, Docker checks if you already have the hello-world image. If not, it downloads it from Docker Hub. Then, it creates a new container from the image, runs it, prints a welcome message, and exits. The output will look something like this:

This confirms that Docker is working and you are ready to start using containers.

Summary And What's Next

In this lesson, you learned what containers are and how they differ from virtual machines. You saw why containers are useful for developers and how Docker helps you work with them. You also checked that Docker is installed and ran your first container using the hello-world image.

Next, you will get a chance to practice these commands yourself and get familiar with the practice environment. You will run the commands, read their output, and answer questions to help you understand how images and containers work. This will prepare you for more advanced topics in Docker.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal