Skip to main content
  1. Posts/

Modern Infrastructure – Part 1: Docker

·675 words·4 mins

β€œBuild once, run anywhere.”

That’s not a dream - that’s Docker.

What is Docker?
#

Docker is an open-source platform that allows you to develop, ship, and run applications inside containers. Containers package your app along with its environment, dependencies, and tools - making them portable, lightweight, and consistent across all platforms.

Why Docker?
#

Traditional VMs vs Docker

FeatureTraditional VMDocker
OS ArchitectureHeavy OS per VMShared kernel, lightweight
Boot TimeSlower boot timeFast boot/startup
Resource UsageMore resources usedLess CPU/RAM needed
PortabilityHard to moveEasy to share or deploy

Use Docker when you want to:

  • Avoid “It works on my machine”
  • Speed up development and CI/CD
  • Build microservices
  • Scale easily

Docker Architecture
#

Core Components:
#

  • Docker Host: Docker Host or Docker Engine is the brain of docker. It conatians docker daemon that runs in the background, manages Docker objects (containers, images, networks).

  • Docker Client: The command-line interface to talk to the daemon.

  • Docker Objects: It includes:

    • Images: Blueprint for containers/app
    • Containers: running instances of app
    • Volumns: Storing persistent data into host system
    • Network:
  • Docker Registries: Central hubs for sharing /storing images (like Docker Hub, GitHub etc).

command screenshot
Developer β†’ Docker CLI β†’ Docker Daemon β†’ Container β†’ Application

Installing Docker
#

Ubuntu:
#

sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker

Check version:

docker --version

Enable running without sudo:

sudo usermod -aG docker $USER

Manjaro KDE:
#

  1. Update your system and install docker:

    command screenshot

  2. Enable docker and check version:

    command screenshot


Basic Docker Commands
#

Working with Images
#

  1. Create a Dockerfile (Script to create an image):
command screenshot
  1. Build an image from dockerfile:

    command screenshot
    command screenshot

  2. Delete an image:

    command screenshot

Working with Containers
#

  1. Run a container from an image:
    command screenshot
    Note: You cannot create two containers with same name.

Open browser http://localhost:8080 , you’ll see:

command screenshot

  1. List active containers:

    command screenshot

  2. List all containers (including stopped ones):

    command screenshot

  3. Stop a running container or remove a container:

    command screenshot

  4. Delete all containers at once:

    command screenshot


Introduction to Docker Compose
#

What is Docker Compose?
#

Docker Compose is a tool to define and manage multi-container applications.

Instead of running containers manually one by one, you define them in a docker-compose.yml file and start them all with a single command.

A sample docker compose.yml file:

command screenshot


Installation of Docker Compose
#

  1. Install docker compose:

    command screenshot

  2. Verify if installation is successful:

    command screenshot

  3. Rebuild images and start containers in background:

    command screenshot

  4. Lists the containers (services) that are running (or have been created) using your docker-compose.yml file:

docker compose ps
  1. Stops all running containers defined in your Compose file, but does not remove them:
docker compose stop
  1. Starts containers that were previously stopped using:
docker compose start
  1. Stops and removes all the containers, networks, and by default also volumes that were created by:
    command screenshot

Docker vs Kubernetes
#

FeatureDockerKubernetes
PurposeContainerizationOrchestration
ScaleManualAuto-scaling, rolling updates
NetworkingSimpleComplex but powerful
Use caseDev & CI/CDProduction, large systems

Real-World Use Cases
#

  • CI/CD Pipelines: Jenkins + Docker

  • Local Dev Environments: VSCode devcontainers

  • Microservices Architecture: API Gateway + Services + DB

  • Edge Computing: IoT and Raspberry Pi deployments

  • App Distribution: One image, many platforms


Conclusion
#

Docker is no longer optional - it’s essential for modern software development. Whether you’re building a Node.js app, a Python API, or a full-stack microservice, Docker gives you consistency, speed, and portability.


Bonus: Quick Reference Sheet
#


sudo systemctl start docker
sudo usermod -aG docker $USER
newgrp docker


docker build -t docker-hello .
docker run -d -p 8080:80 docker-hello

docker ps                     # See running containers
docker ps -a                  # See all containers (even stopped ones)
docker stop hello-container   # Stop a running container 
docker start hello-container  # Start it again
docker rm hello-container     # Remove a container 
docker images                 # List all images 
docker rmi docker-hello       # Remove an image

sudo pacman -S docker-compose

v2 β†’ docker compose up -d
v1 β†’ docker-compose up -d


docker compose ps         # Show running services
Open browser http://localhost:8080
docker compose stop       # Stop all services
docker compose start      # Start them again
docker compose down       # Stop & remove everything