How to Set Up Docker on Ubuntu 20.04, 22.04, and 24.04 LTS – From Installation to Multi-Container Deployment
New to Docker? This in-depth guide walks you through installing Docker on Ubuntu LTS, managing images, running containers, and deploying full-stack apps with internal networking.

🐳 Introduction to Docker
Docker simplifies app deployment by packaging code and dependencies into portable containers. It’s widely used for both development and production environments due to its consistency and efficiency.
🔧 Installing Docker on Ubuntu 20.04, 22.04, and 24.04 LTS
Step 1: Uninstall Old Versions (if any)
bash
sudo apt remove docker docker-engine docker.io containerd runcStep 2: Update Packages & Install Dependencies
bash
sudo apt update sudo apt install apt-transport-https ca-certificates curl software-properties-commonStep 3: Add Docker’s GPG Key
bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgStep 4: Add Docker’s Repository
bash
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/nullStep 5: Install Docker Engine
bash
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.ioStep 6: Verify Docker Installation
bash
sudo docker --version sudo docker run hello-world📦 Getting and Creating Docker Images
Use Prebuilt Images (from Docker Hub)
bash
docker pull nginx docker pull nodeBrowse: https://hub.docker.com
Create Your Own Docker Image
Create a Dockerfile:
Dockerfile
# For Node.js app FROM node:18 WORKDIR /app COPY . . RUN npm install CMD ["npm", "start"] EXPOSE 3000Then build it:
bash
docker build -t my-node-app .🧰 Useful Docker Commands
CommandDescriptiondocker psShow running containersdocker imagesList local imagesdocker exec -it <id> bashEnter running containerdocker stop <id>Stop a containerdocker rm <id>Remove a containerdocker rmi <id>Remove an image
🕸️ Containerizing Multiple Servers (Frontend + Backend)
Folder structure:
project-root/ ├── backend/ │ └── Dockerfile ├── frontend/ │ └── Dockerfile └── docker-compose.yml
docker-compose.yml:
yaml
version: '3' services: frontend: build: ./frontend ports: - "3000:3000" depends_on: - backend backend: build: ./backend ports: - "5000:5000" environment: - NODE_ENV=productionRun everything:
bash
docker-compose up --buildInternal Networking
Docker Compose automatically creates a default network.
Services can communicate using their service name (
frontend,backend) as hostname.
Example: Your frontend can make an API call to http://backend:5000/api.
✅ Wrapping Up
You now know how to:
Install Docker on Ubuntu LTS
Use Docker images and containers
Build custom images
Deploy full-stack apps using Docker Compose
Utilize Docker networking for internal communication
Docker is an essential tool for modern DevOps and deployment workflows. Master it once, and you’ll level up your development and deployment pipeline.
Share this article
Admin User
Admin User
Related Posts

How to Set Up Redis in Node.js on Ubuntu 20.04/22.04/24.04 LTS
Learn how to install and configure Redis with Node.js on Ubuntu 20.04, 22.04, or 24.04 LTS. This step-by-step guide ensures high-performance caching and data storage for your Node.js apps.

The Enduring Importance of Data Structures & Algorithms
In an age where AI seems to handle everything from chatbots to complex simulations, the fundamentals of Data Structures & Algorithms (DSA) remain the cornerstone of every efficient, scalable, and innovative software solution. Here’s why, even in 2025, DSA skills are non-negotiable for any developer aiming to thrive.

Average Salaries in India (2025) for Developers & Designers Based on Experience
Planning a career in tech or design? This detailed guide breaks down the average salary in India for developers (Node.js, Java, Python, Django) and designers based on experience—from fresher to 4+ years.

Ubuntu 24.04 LTS Installation Guide for Any PC – From BIOS to Developer Setup
Want to install Ubuntu 24.04 LTS on your PC? This universal guide covers BIOS setup, swap memory recommendations, partitioning, and essential post-install commands for all systems.
