Cloud Native 12 min read

Master Docker in 2 Hours: From Basics to Full Image Lifecycle

This guide walks you through Docker fundamentals, its container‑based virtualization, installation on Windows and Ubuntu, architecture components, image concepts, and a hands‑on workflow that covers pulling, running, building, and pushing images, all illustrated with clear examples and diagrams.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Docker in 2 Hours: From Basics to Full Image Lifecycle

In the first two hours you’ll fall in love with Docker, gaining a basic understanding of its principles and workflow while avoiding endless, unfocused research.

What is Docker?

Unlike KVM, VirtualBox, or VMware that virtualize entire machines, Docker virtualizes the operating system to isolate applications, giving each container its own filesystem, network stack, and PID namespace while sharing the host kernel.

With Docker, two processes can run in separate containers, each believing it has its own root filesystem and network interface, even sharing the same PID number without conflict.

Virtual machines, by contrast, duplicate entire operating systems, making each process think it runs on a separate physical computer.

Why can Docker “virtualize”?

Docker achieves a lightweight form of virtualization by using Linux namespaces to create isolated environments, allowing multiple independent groups (managers) to operate on the same kernel without interfering with each other.

Further extensions can create separate manager groups for sound cards, network cards, etc., each enjoying its own namespace.

Installing Docker

On Windows, download Docker Toolbox, close any conflicting software (e.g., 360), and run Docker Quickstart Terminal after installation.

On Ubuntu, follow the official guide (https://docs.docker.com/engine/installation/linux/ubuntu/) or simply run: sudo apt-get update && apt-get install docker After installation, add your user to the docker group and restart Docker services.

Register a Docker Hub account (e.g., username 21cnbao) to push your own images.

Docker Architecture

A typical Docker setup involves a client issuing commands, a Docker host running the daemon, and a registry (default Docker Hub) storing images. The client and host can reside on the same machine.

Workflow: the client pulls an image from the registry, then runs a container from that image. Conversely, the client can build a new image on the host and push it to the registry.

What is an Image?

An image is a layered filesystem containing the program, libraries, resources, and configuration needed to run a container. Layers are immutable; each new layer adds changes without altering previous ones, similar to Git commits.

The topmost layer becomes the running container; modifications inside the container do not affect the underlying image.

Complete Docker Practice

1. Pull an Image

Use the docker pull command: docker pull [options] [registry/]repository[:tag] Example pulling Ubuntu 14.04:

List downloaded images:

2. Run a Container

Start two instances of the Ubuntu 14.04 image, each running a Bash shell:

Both containers run the same image but are independent processes, similar to multiple instances of a program.

3. Build a Custom Image

Create a Dockerfile that adds vim and gcc to the Ubuntu base:

Build the image:

Run the new image to verify vim and gcc are available:

4. Push the Image to Docker Hub

Create a repository named myubuntu on Docker Hub (full name 21cnbao/myubuntu).

Log in to Docker Hub, then push the image:

Verify the repository now contains the new image.

After two hours of hands‑on practice, you should have a solid foundation in Docker and be ready to explore more advanced topics.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeDockerLinuxContainersImage Building
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.