Trong modern DevOps landscape, Docker đã chuyển từ “nice-to-have” thành một absolute industry standard. Dù bạn là developer tìm kiếm environment consistency hay sysadmin hướng tới resource efficiency, Docker là go-to tool của bạn để đóng gói applications vào lightweight, portable containers.
Khác với traditional Virtual Machines (VMs), Docker containers share host OS kernel. Lựa chọn architectural này khiến chúng incredibly fast, resource-friendly, và easy to scale.
Tại Sao Chọn Docker?
Trước khi dive vào terminal, hãy xem tại sao Docker là preferred choice cho hàng triệu developers:
- Environmental Consistency: “It works on my machine” là chuyện của quá khứ. Apps chạy identically across dev, staging, và production.
- Resource Efficiency: Vì containers không cần full guest OS, chúng consume significantly less CPU và RAM hơn VMs.
- Rapid Deployment: Launch applications trong seconds thay vì minutes.
- Isolation: Run multiple apps với conflicting dependencies trên cùng host mà không có “DLL hell” hay version friction.
Prerequisites
Để đảm bảo smooth installation trên Ubuntu 24.04 LTS (Noble Numbat), verify system của bạn meets các specs này:
- RAM: 4GB minimum (8GB recommended cho production).
- Disk Space: Ít nhất 20GB free space.
- Privileges: Một user account với
sudoaccess. - Architecture: 64-bit version của Ubuntu.
Check version nhanh với:
lsb_release -a
Method 1: The Pro Way (Official Docker Repository)
Đây là recommended method. Bằng cách linking trực tiếp đến official Docker repository, bạn đảm bảo nhận latest stable releases và critical security patches automatically.
Step 1: Refresh Your System
Start với một clean slate bằng cách updating local package index:
sudo apt update && sudo apt upgrade -y
Step 2: Install Essential Dependencies
Install các tools cần thiết để Ubuntu communicate với external repositories qua HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
Step 3: Secure the Source (GPG Key)
Add official Docker GPG key để đảm bảo software bạn đang downloading là authentic:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Step 4: Add the Docker Repository
Giờ, tell system của bạn nơi để tìm Docker packages:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 5: Install Docker Engine
Update package list lần cuối và install Docker suite:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Method 2: The Fast Way (Convenience Script)
Short on time? Docker cung cấp một automated script cho testing và development environments.
Note: Đây là great cho quick lab setup nhưng generally avoided trong production vì security reasons.
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Post-Installation Polish
1. Enable Autostart
Ensure Docker kicks in mỗi khi system boots:
sudo systemctl enable docker
sudo systemctl start docker
2. Run Docker without Sudo
Nếu bạn tired of typing sudo trước mỗi command, add user của bạn vào Docker group:
sudo usermod -aG docker $USER
newgrp docker
The Moment of Truth: Verify the Setup
Hãy xem mọi thứ có working correctly không. First, check version: docker --version
Sau đó, run “Hello World” container—rite of passage cho mọi Docker user:
docker run hello-world
Nếu bạn thấy message nói “Hello from Docker!”, xin chúc mừng! Bạn đã officially ready để start containerizing applications của mình.


