Cloud Native 17 min read

Unlock Docker: From Zero to Deploying Your First Containerized App

This guide walks you through Docker fundamentals, comparing containers to virtual machines, explaining core concepts, installation, building and running a Vue project inside an Nginx container, and provides best practices and commands for image creation, container management, and deployment, enabling you to master containerization from scratch.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Unlock Docker: From Zero to Deploying Your First Containerized App

In the era of rich web applications, complexity grows with cluster deployment, isolated environments, gray releases, and dynamic scaling; containerization becomes the essential bridge.

1. A Story

Imagine building a house by moving stones, cutting wood, drawing plans, and constructing it. When you want to move the house to the sea, you must repeat the whole process. A wizard teaches you a magic that creates a "image" of the house you can pack in a backpack and redeploy anywhere—just like Docker images and registries (Build once, run anywhere).

No more worries about version, compatibility, or deployment failures.

2. Virtual Machines vs. Containers

Virtual Machine : Software emulates a full hardware system, providing complete isolation. Each VM has its own disk, memory, and OS. Examples: VMWare, OpenStack.

Container : OS‑level virtualization that packages code, dependencies, and configuration, ensuring consistent execution across environments.

Run anywhere

High resource utilization

Fast scaling

Differences:

VMs are larger, slower to start, and often require paid software.

Containers virtualize only a small environment (sandbox).

VMs need gigabytes; containers need megabytes or kilobytes.

Containers are lightweight virtualization, while Docker is a container engine.

3. Understanding Docker

Docker is an open‑source application container engine that packages applications and their dependencies into portable containers, which run on any Linux host using sandbox mechanisms.

Docker’s three core concepts: Image , Container , and Repository .

Why is Docker lightweight?

Docker creates a resource‑isolated environment (namespace) and copies the application into it, then runs the specified command. Images contain no dynamic data and remain unchanged after build.

4. Core Concepts

Build

,

Ship and Run
Build once

, Run anywhere Docker is a tool that creates containers, not a container itself.

Docker’s three core concepts: Image, Container, Repository.

Docker uses Linux kernel features (cgroups, namespaces) for isolation.

On non‑Linux hosts Docker runs a Linux VM to host containers.

An image is an executable package; a container is a runtime instance of that image.

5. Installing Docker

1. Command‑line installation (macOS example): brew cask install docker 2. Verify version: docker -v 3. Configure image mirrors (example JSON):

{
  "registry-mirrors": [
    "http://hub-mirror.c.163.com/",
    "https://registry.docker-cn.com"
  ],
  "insecure-registries": [],
  "experimental": false,
  "debug": true
}

4. Install Docker Desktop (download from official site).

6. Quick Start

Create a Vue project and build it:

vue create docker-demo
yarn serve
yarn build

Project’s dist folder contains static files.

Create Dockerfile:

FROM nginx
COPY dist/ /usr/share/nginx/html/
COPY default.conf /etc/nginx/conf.d/default.conf

Explanation: FROM nginx – base image. COPY dist/ /usr/share/nginx/html/ – copy built files. COPY default.conf /etc/nginx/conf.d/default.conf – replace Nginx config.

Build the image: docker build -t jartto-docker-demo . Resulting image size ~133 MB.

Run the container:

docker run -d -p 3000:80 --name docker-vue jartto-docker-demo

Parameters: -d – run in background. -p 3000:80 – map host port 3000 to container port 80. --name docker-vue – container name.

Verify with docker ps -a and access via localhost:3000 or curl -v -i localhost:3000.

7. Publishing the Image

Log in to Docker Hub.

Tag the image: docker tag jartto-docker-demo username/repo:tag Push: docker push username/repo:tag After publishing, you can deploy the image without rebuilding the house.

8. Common Dockerfile Instructions

FROM

– base image. MAINTAINER – image author. RUN – execute command during build. ADD – copy and optionally extract. COPY – copy files. CMD – default command when container starts (overridable). ENTRYPOINT – command that cannot be overridden. LABEL – metadata. ENV – environment variables. EXPOSE – declare listening port. VOLUME – define mount points. WORKDIR – set working directory. USER – specify user. ARG – build‑time variable.

9. Best Practices

Specify required image clearly.

Minimize steps; prioritize stable layers.

Use explicit version tags.

Document the build process for reproducibility.

10. Conclusion

Containerization is a vital skill for the cloud era; Docker is just the beginning. Mastering Docker opens the path to orchestration tools like Kubernetes, Service Mesh, and Istio, revealing the limitless potential of container technology.

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.

DockerDevOpscontainerizationFrontend Deployment
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.