Cloud & DevOps

What Is Docker? Containers Explained for Beginners

A beginner's guide to Docker: what images and containers are, why teams use them, and a first hands-on example you can run in about 15 minutes.

Quick answer

Docker is a platform for packaging an application and everything it needs into a container, a lightweight, isolated unit that runs the same way on any computer or cloud. You describe the app in a Dockerfile, build it into an image and run that image as a container. It removes the "works on my machine" problem and speeds up development.

What Is Docker? Containers Explained for Beginners

Photo: Unsplash

On this page

A new developer joins your team and spends 2 days installing the right versions of a programming language, a database and a dozen libraries before the app runs on their laptop. Then the app behaves differently on the server anyway. Docker exists to make that story disappear.

This guide explains Docker for beginners: what containers, images and Dockerfiles are, why businesses use them, what Docker costs, and a first hands-on example you can run yourself.

What Docker is

Docker is a platform for building, sharing and running applications in containers. Docker’s own documentation calls it “an open platform for developing, shipping, and running applications.”

A container packages an application together with everything it needs to run: code, runtime, libraries, system tools and settings. Because the package is self-contained, the app runs the same way on a developer’s laptop, a test server and a production cloud server.

Docker was released as open source in 2013 and quickly became the best-known way to work with containers. Today, “Docker” can mean 3 things:

  • Docker Engine: the open source software that builds and runs containers
  • Docker Desktop: an app for Windows, Mac and Linux that bundles Docker Engine with a graphical interface and developer tools
  • Docker Hub: a public registry where people share container images

Containers vs virtual machines

Containers are often compared to virtual machines (VMs), and the difference matters.

Factor Containers Virtual machines
What is packaged App plus its dependencies Full operating system plus app
Shares host OS kernel Yes No, each VM has its own OS
Typical size Megabytes to a few hundred megabytes Often gigabytes
Startup time Usually seconds or less Usually minutes
Isolation Process-level isolation Stronger, hardware-level isolation
Best for Modern apps, microservices, consistent dev environments Legacy software, different operating systems, strict isolation

Containers are lighter and faster because they share the host’s operating system kernel instead of running a full operating system each. VMs still have their place, and containers often run inside VMs in the cloud.

The 4 Docker terms you need to know

1. Dockerfile. A plain text file with step-by-step instructions for building an image: which base image to start from, which files to copy in, which commands to run and how to start the app. Docker’s documentation notes that each instruction creates a layer, and when you rebuild, only changed layers are rebuilt, which keeps builds fast.

2. Image. A read-only template built from a Dockerfile. Think of it as a recipe card or a frozen snapshot of your app and its environment. Images are often built on top of other images, such as an official base image for a language or web server.

3. Container. A running instance of an image. You can run many containers from the same image. Docker’s documentation warns that changes inside a container that are not saved to persistent storage are lost when the container is removed, so databases and uploaded files need volumes or external storage.

4. Registry. A place to store and share images. Docker Hub is the default public registry, and you can use private registries, including those offered by AWS, Azure and Google Cloud.

The flow is simple: Dockerfile → build → image → run → container.

Key takeaway: An image is the packaged recipe; a container is the running dish. You write a Dockerfile once, build an image, and run identical containers anywhere Docker is available.

Why businesses use Docker

  • Consistent environments. The same image runs in development, testing and production, which removes a large class of “works on my machine” bugs.
  • Faster onboarding. New developers can start a project’s full environment with 1 or 2 commands instead of a long setup guide.
  • Portability. Containers run on laptops, on-premise servers and every major cloud, which reduces dependence on any one host.
  • Efficient use of servers. Many containers can share 1 server, using resources more efficiently than 1 VM per app.
  • Foundation for modern deployment. Container images feed directly into CI/CD pipelines, managed container services and Kubernetes. Our guide to Docker vs Kubernetes explains how they fit together.

Your first hands-on example

This walkthrough takes about 15 minutes. You will run a test container, then build and run a tiny website in your own container.

Step 1: Install Docker

Install Docker Desktop for Windows or Mac from Docker’s website, or Docker Engine on Linux. Open a terminal (Command Prompt, PowerShell or Terminal) and check it works:

docker --version

Step 2: Run your first container

docker run hello-world

Docker looks for the hello-world image on your computer, does not find it, downloads it from Docker Hub, creates a container and runs it. You should see a message confirming that your installation works. That is the whole life cycle in 1 command: pull, create, run.

Step 3: Create a tiny website

Make a new folder called my-first-container. Inside it, create a folder called site, and inside site create a file named index.html containing 1 line of plain text:

Hello from my first container

Step 4: Write a Dockerfile

In the my-first-container folder (not inside site), create a file named Dockerfile with no file extension:

FROM nginx:alpine COPY site /usr/share/nginx/html

The first line starts from the official Nginx web server image, using a small Alpine Linux variant. The second copies your site files into the folder Nginx serves by default. This follows the static content pattern shown on the official Nginx image page on Docker Hub.

Step 5: Build the image

From inside my-first-container, run:

docker build -t my-first-site .

The -t flag gives the image a name (a tag), and the . tells Docker to use the current folder.

Step 6: Run the container

docker run -d -p 8080:80 --name my-site my-first-site

Here is what each part means: - -d runs the container in the background - -p 8080:80 connects port 8080 on your computer to port 80 inside the container - --name my-site gives the container a friendly name

Open a browser and go to localhost:8080. You should see “Hello from my first container.”

Step 7: Look around and clean up

docker ps docker stop my-site docker rm my-site

docker ps lists running containers. The other 2 commands stop and remove your container. The image stays on your computer, so you can start a new container from it any time.

Congratulations: you have built and run your own container image. The same pattern scales to real applications in Python, Node.js, Java or .NET, using their official base images.

What to learn next

Next step What it does When you need it
Docker Compose Runs multi-container apps (for example, app plus database) from 1 file Almost immediately for real projects
Volumes Keeps data when containers are removed Any app that stores data
Registries Shares images with your team and servers When deploying beyond your laptop
Image security scanning Finds known vulnerabilities in image contents Before anything goes to production
Managed container services Runs containers in the cloud without managing servers For your first production deployment
Kubernetes Orchestrates many containers across many servers When you run many services at scale

For a deeper look at orchestration, read Kubernetes explained. If you are weighing containers against functions, our guide to serverless computing compares them.

Costs, licensing and security basics

Licensing. Docker Engine is open source. Docker Desktop is free for personal use, education, non-commercial open source projects and small businesses with fewer than 250 employees and less than $10 million in annual revenue (both conditions must be met). Larger organizations and government entities need a paid Docker subscription for professional use. Check Docker’s current terms before rolling it out company-wide.

Security basics for beginners: - Use official or verified base images from trusted publishers - Keep base images updated, and rebuild regularly to pick up security patches - Never put passwords or API keys directly in a Dockerfile or image - Run containers with only the permissions they need - Scan images for known vulnerabilities before production

These habits fit into a broader zero trust security approach.

The bottom line

Docker packages applications and their dependencies into containers that run the same way everywhere. You write a Dockerfile, build an image and run containers from it. For businesses, that means faster onboarding, fewer environment bugs and an easy path to the cloud. Start with the hands-on example above, then learn Docker Compose and volumes. If you are building skills for a career move, our guide on how to become a DevOps engineer shows where Docker fits.

Sources

Questions readers ask

Frequently asked questions

What is Docker in simple terms?

Docker is a tool that packages an application and everything it needs, such as code, libraries and settings, into a container. That container runs the same way on any computer or server with Docker installed. It saves developers from installing and configuring software by hand on each machine and reduces bugs caused by differences between environments.

What is the difference between a Docker image and a container?

A Docker image is a read-only template that contains your application and its environment, built from a Dockerfile. A container is a running instance of that image. You can start many containers from 1 image, just as you can bake many cakes from 1 recipe. Changes made inside a container are lost when it is removed unless saved to a volume.

Is Docker free to use?

Docker Engine is open source and free. Docker Desktop is free for personal use, education, non-commercial open source and small businesses with fewer than 250 employees and less than $10 million in annual revenue. Larger companies and government entities need a paid Docker subscription for professional use of Docker Desktop. Check Docker's current license terms before adopting it.

Is Docker the same as a virtual machine?

No. A virtual machine includes a full operating system, while a Docker container shares the host computer's operating system kernel and packages only the app and its dependencies. That makes containers smaller and faster to start, often in seconds. Virtual machines offer stronger isolation and can run different operating systems, so many cloud setups run containers inside virtual machines.

Do I need to know Linux to use Docker?

Basic Linux knowledge helps but is not required to start. Docker Desktop runs on Windows and Mac, and simple examples work with a handful of commands. As you write more Dockerfiles, you will use common Linux commands for installing packages and managing files, because most container images are based on Linux. Learning the basics alongside Docker is a good approach.

What is Docker used for in business?

Businesses use Docker to give every developer an identical environment, speed up onboarding, package applications for testing and deployment, and run apps consistently across laptops, servers and clouds. It is also the standard starting point for CI/CD pipelines, managed container services and Kubernetes. Even small teams benefit from fewer environment-related bugs and easier moves between hosting providers.

How long does it take to learn Docker?

Most people can run containers and write a simple Dockerfile within a day or 2 of practice. Becoming comfortable with Docker Compose, volumes, networking, image optimization and security basics typically takes a few weeks of regular use on real projects. Learning to run containers in production at scale, including orchestration with Kubernetes, takes considerably longer.

Reader reviews

Was this guide useful

No reviews yet. Share your experience and help other readers.

Write a review
Your rating
Never shown publicly

Reviews are checked before they appear. We never show your email. Please review only places or services you have used.

Manishdai
Written by

Manishdai

Manishdai writes about the technology that is reshaping every industry — from AI agents and cloud platforms to healthtech, fintech and the IT companies building it all across the United States.