DockerGetting Started

Getting Started with Docker

This guide will help you install Docker, run your first container, and learn essential Docker commands.

11 min read

Getting Started with Docker

This guide will help you install Docker, run your first container, and learn essential Docker commands.

Installation

macOS

Docker Desktop (Recommended):

  1. Visit https://docs.docker.com/desktop/install/mac-install/
  2. Download Docker Desktop for Mac (Intel or Apple Silicon)
  3. Open the .dmg file and drag Docker to Applications
  4. Launch Docker Desktop
  5. Docker icon appears in menu bar when running

Verify Installation:

Alternative: Homebrew:

Windows

Docker Desktop (Recommended):

  1. Visit https://docs.docker.com/desktop/install/windows-install/
  2. Download Docker Desktop for Windows
  3. Run installer
  4. Enable WSL 2 (Windows Subsystem for Linux) if prompted
  5. Restart computer
  6. Launch Docker Desktop

System Requirements:

  • Windows 10 64-bit: Pro, Enterprise, or Education (Build 19041 or higher)
  • OR Windows 11 64-bit: Home, Pro, Enterprise, or Education
  • WSL 2 enabled
  • Hyper-V enabled (automatic)

Verify Installation:

Linux (Ubuntu/Debian)

Install Docker Engine:

Post-Install Steps (run Docker without sudo):

Install Docker Compose:

Your First Container

Hello World

Run the classic first container:

What happened?:

Explanation:

Interactive Container

Run Ubuntu container with interactive shell:

Inside the container:

Flags explained:

  • -i: Interactive (keep STDIN open)
  • -t: Allocate pseudo-TTY (terminal)
  • ubuntu: Image name
  • bash: Command to run

Background Container

Run Nginx web server in background:

Test it:

Manage the container:

Essential Docker Commands

Image Management

Container Management

Inspecting Containers

Executing Commands in Containers

Building Your First Image

Create a Simple Python App

1. Create application files:

app.py:

requirements.txt:

2. Create Dockerfile:

3. Build the image:

4. Run the container:

Understanding the Build Process

What happens during docker build:

View build history:

Using Docker Compose

Multi-Container Application

Scenario: Flask app + PostgreSQL database

1. Project structure:

app.py (updated):

requirements.txt (updated):

docker-compose.yml:

2. Run the application:

3. Manage services:

Working with Volumes

Persistent Data

Problem: Container data is lost when container is removed

Solution: Use volumes

Named Volume Example:

Bind Mount Example

Development workflow with live code reload:

Networking

Container Communication

Default bridge network:

Custom bridge network (recommended):

List networks:

Cleaning Up

Remove Unused Resources

Common Issues & Solutions

Issue: Port Already in Use

Issue: Container Exits Immediately

Issue: Cannot Connect to Container

Issue: Permission Denied

Next Steps

Learning Path

  1. Practice building images: Create Dockerfiles for different languages
  2. Use Docker Compose: Set up multi-container applications
  3. Explore Docker Hub: Find official images for databases, tools
  4. Learn networking: Understand how containers communicate
  5. Study volumes: Master persistent data storage
  6. Security: Learn image scanning, secrets management
  7. Orchestration: Move to Kubernetes or Docker Swarm

Recommended Practice Projects

  1. Containerize existing app: Take a simple app and dockerize it
  2. Multi-tier app: Web + API + Database with Docker Compose
  3. Development environment: Database, cache, message queue
  4. Data pipeline: Airflow + dbt + PostgreSQL
  5. Microservices: Multiple services communicating

Resources

Ready for advanced topics? Check out:

Stay in the loop

Get weekly insights on data engineering, analytics, and AI—delivered straight to your inbox.

No spam. Unsubscribe anytime.