🐳 Docker Fundamentals

AWSomeVikashAWSomeVikash
2 min read

βš™οΈ How Containers Work

  • Containers do not consume pre-allocated resources like virtual machines.

  • They use shared system resources (CPU, RAM, storage).

  • If a container needs only 200MB of space, it will consume only 200MB, not more.

πŸ’‘ Containerization is made possible through Docker.

🧠 Hypervisor vs Docker

  • Hypervisor: Used in virtual machines (e.g., VirtualBox, VMware). It allocates separate OS and resources to each VM.

  • Docker: Uses shared OS kernel (specifically Linux kernel) to run containers more efficiently with fewer resources.

🐧 Installing Docker (on Ubuntu)

sudo apt-get update

sudo apt-get install docker.io

sudo systemctl start docker

sudo systemctl enable docker

sudo systemctl status docker

🍏 Installing Docker (on macOS)

brew install --cask docker

docker --version

πŸ” How Docker Works

Docker consists of the following components:

  • Docker CLI β†’ Command Line Interface

  • Docker Daemon (dockerd) β†’ Runs in the background and manages containers/images

  • Containers β†’ Lightweight isolated environments to run apps

  • Docker Images β†’ Blueprints used to create containers

Flow:

DOCKER CLI β†’ Docker Daemon β†’ Container

πŸ§ͺ Common Docker Commands

  • docker ps β†’ Lists running containers

  • cat /etc/group β†’ Checks if you’re in the docker group

  • If not in the group:

sudo usermod -aG docker $USER

newgrp docker # Refresh group membership

🧠 $USER is an environment variable representing the currently logged-in user.

πŸš€ Docker File β†’ Image β†’ Container

  • A Dockerfile is used to create a Docker image.

  • An image is like a blueprint.

  • A container is a running instance of that image.

Without a Dockerfile, you can directly pull and run prebuilt images using DockerHub.

πŸ› οΈ Example Docker Run Commands

docker run -it ubuntu ,,,, Interactive terminal

docker run -itd ubuntu ,,,, Interactive + detached (runs in background)

docker run -d -p 80:80 nginx ,,,,, Run nginx in background and expose port 80

docker run -it -d -p 80:80 nginx …….Interactive + detached nginx

β›” Stopping a Container

docker stop <container_id>

0
Subscribe to my newsletter

Read articles from AWSomeVikash directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

AWSomeVikash
AWSomeVikash

πŸš€ Hi, I'm Vikash Patel β€” a passionate AWS & DevOps enthusiast, sharing my complete learning journey and real-world implementations. πŸ“˜ On this blog, I’m publishing a full DevOps + AWS roadmap β€” from basics to advanced, covering: 🟑 AWS Services: EC2, S3, IAM, CloudWatch, Billing, and more 🐧 Linux commands & scripting βš™οΈ CI/CD pipelines with GitHub Actions & Jenkins 🧱 Infrastructure as Code using Terraform πŸ“ˆ Monitoring, Alerts & Troubleshooting πŸ’‘ Every post is beginner-friendly β€” focused on clarity, practical use-cases, and hands-on solutions. 🌐 I’m also building my presence in the AWS Community, sharing what I learn, and learning from others. 🌱 Whether you're starting your cloud journey or looking for practical DevOps solutions, this blog is for you.